elsa-core/src/modules/Elsa.Http/Handlers/UpdateRouteTable.cs

29 lines
1.1 KiB
C#
Raw Normal View History

using Elsa.Extensions;
using Elsa.Http.Contracts;
using Elsa.Mediator.Contracts;
using Elsa.Workflows.Runtime.Notifications;
2022-04-27 20:32:40 +00:00
namespace Elsa.Http.Handlers;
public class UpdateRouteTable :
INotificationHandler<WorkflowTriggersIndexed>,
INotificationHandler<WorkflowBookmarksIndexed>
2022-04-27 20:32:40 +00:00
{
private readonly IRouteTable _routeTable;
public UpdateRouteTable(IRouteTable routeTable) => _routeTable = routeTable;
2022-04-27 20:32:40 +00:00
public Task HandleAsync(WorkflowTriggersIndexed notification, CancellationToken cancellationToken)
{
_routeTable.RemoveRoutes(notification.IndexedWorkflowTriggers.RemovedTriggers);
_routeTable.AddRoutes(notification.IndexedWorkflowTriggers.AddedTriggers);
_routeTable.AddRoutes(notification.IndexedWorkflowTriggers.UnchangedTriggers);
return Task.CompletedTask;
}
2022-04-27 20:32:40 +00:00
public Task HandleAsync(WorkflowBookmarksIndexed notification, CancellationToken cancellationToken)
{
_routeTable.RemoveRoutes(notification.IndexedWorkflowBookmarks.RemovedBookmarks);
_routeTable.AddRoutes(notification.IndexedWorkflowBookmarks.AddedBookmarks);
return Task.CompletedTask;
2022-04-27 20:32:40 +00:00
}
}