2020-12-14 18:57:33 +00:00
|
|
|
using Elsa.Activities.Entity;
|
|
|
|
|
using Elsa.Activities.Console;
|
|
|
|
|
using Elsa.Builders;
|
|
|
|
|
using Elsa.Activities.Entity.Models;
|
|
|
|
|
|
|
|
|
|
namespace Elsa.Samples.EntityChanged
|
|
|
|
|
{
|
2020-12-14 20:12:37 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// This workflow gets invoked whenever an entity is added to the repository.
|
|
|
|
|
/// It then blocks execution until the entity is deleted.
|
|
|
|
|
/// </summary>
|
2020-12-14 18:57:33 +00:00
|
|
|
public class EntityChangedWorkflow : IWorkflow
|
|
|
|
|
{
|
|
|
|
|
public void Build(IWorkflowBuilder workflow)
|
|
|
|
|
{
|
|
|
|
|
workflow
|
2021-01-08 10:40:07 +00:00
|
|
|
.WithContextType<Entity>()
|
2020-12-14 18:57:33 +00:00
|
|
|
.EntityChanged<Entity>(EntityChangedAction.Added)
|
2021-01-08 10:40:07 +00:00
|
|
|
.WriteLine(context => $"Entity '{context.GetInput<EntityChangedContext>()!.EntityId}' was '{context.GetInput<EntityChangedContext>()!.Action}'")
|
2020-12-14 20:12:37 +00:00
|
|
|
.EntityChanged<Entity>(EntityChangedAction.Deleted)
|
2021-01-08 10:40:07 +00:00
|
|
|
.WriteLine(context => $"Entity '{context.GetInput<EntityChangedContext>()!.EntityId}' was '{context.GetInput<EntityChangedContext>()!.Action}'");
|
2020-12-14 18:57:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|