using Elsa.Mediator.Contracts;
using Elsa.Workflows.Runtime.Contracts;
using Elsa.Workflows.Runtime.Filters;
using Elsa.Workflows.Runtime.Notifications;
namespace Elsa.Workflows.Runtime.Services;
///
/// Default implementation of .
///
public class DefaultBookmarkManager : IBookmarkManager
{
private readonly IBookmarkStore _bookmarkStore;
private readonly INotificationSender _notificationSender;
///
/// Initializes a new instance of the class.
///
public DefaultBookmarkManager(IBookmarkStore bookmarkStore, INotificationSender notificationSender)
{
_bookmarkStore = bookmarkStore;
_notificationSender = notificationSender;
}
///
public async Task 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;
}
}