elsa-core/src/modules/Elsa.Workflows.Runtime/Services/DefaultBookmarkManager.cs
Sipke Schoorstra c9ca4a121d
Workflow Inbox (#4292)
* Initial implementation of workflow inbox, submission and delivery

* Implement persistence providers

* Update EF Core migrations

* Rename Services to Stores in Dapper module

* Use default serializer for primitive arrays

* Update MongoDB provider to map BookmarkId to be primary key

* Implement MongoDB provider for activity execution logs

* Use EF Core by default

* Fix private JSON constructor logic
2023-08-06 17:03:36 +02:00

34 lines
1.3 KiB
C#

using Elsa.Mediator.Contracts;
using Elsa.Workflows.Runtime.Contracts;
using Elsa.Workflows.Runtime.Filters;
using Elsa.Workflows.Runtime.Notifications;
namespace Elsa.Workflows.Runtime.Services;
/// <summary>
/// Default implementation of <see cref="IBookmarkManager"/>.
/// </summary>
public class DefaultBookmarkManager : IBookmarkManager
{
private readonly IBookmarkStore _bookmarkStore;
private readonly INotificationSender _notificationSender;
/// <summary>
/// Initializes a new instance of the <see cref="DefaultBookmarkManager"/> class.
/// </summary>
public DefaultBookmarkManager(IBookmarkStore bookmarkStore, INotificationSender notificationSender)
{
_bookmarkStore = bookmarkStore;
_notificationSender = notificationSender;
}
/// <inheritdoc />
public async Task<long> DeleteManyAsync(BookmarkFilter filter, CancellationToken cancellationToken = default)
{
var bookmarks = (await _bookmarkStore.FindManyAsync(filter, cancellationToken)).ToList();
await _notificationSender.SendAsync(new BookmarksDeleting(bookmarks), cancellationToken);
var count = await _bookmarkStore.DeleteAsync(filter, cancellationToken);
await _notificationSender.SendAsync(new BookmarksDeleted(bookmarks), cancellationToken);
return count;
}
}