forked from elsa-workflows/elsa-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HungryWorkflow.cs
39 lines (36 loc) · 1.26 KB
/
HungryWorkflow.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System.Collections.Generic;
using Elsa.Http;
using Elsa.Workflows.Core.Abstractions;
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Contracts;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Runtime.Activities;
using Microsoft.AspNetCore.Http;
namespace Elsa.Samples.AspNet.Webhooks.WorkflowServer.Workflows;
public class HungryWorkflow : WorkflowBase
{
protected override void Build(IWorkflowBuilder builder)
{
var deliveredFood = builder.WithVariable<string>();
builder.Root = new Sequence
{
Activities =
{
new HttpEndpoint
{
Path = new("/hungry"),
SupportedMethods = new (new[]{HttpMethods.Post}),
CanStartWorkflow = true
},
new WriteLine("Hunger detected!"),
new RunTask("OrderFood")
{
Payload = new(new Dictionary<string, object>() { ["Food"] = "Pizza" }),
Result = new Output<object>(deliveredFood)
},
new WriteLine(context => $"Eating the {deliveredFood.Get(context)}"),
new WriteLine("Hunger satisfied!")
}
};
}
}