elsa-core/src/samples/Sample17/CreatePersonWorkflow.cs
Sipke Schoorstra 82ce170f8d Update Sample17
2019-10-24 21:45:19 +02:00

41 lines
1.6 KiB
C#

using Elsa.Activities.Console.Activities;
using Elsa.Activities.Primitives;
using Elsa.Expressions;
using Elsa.Services;
using Elsa.Services.Models;
using Sample17.Activities;
using Sample17.Models;
namespace Sample17
{
public class CreatePersonWorkflow : IWorkflow
{
public void Build(IWorkflowBuilder builder)
{
builder
.StartWith<WriteLine>(x => x.TextExpression = new LiteralExpression("Enter name:"))
.Then<ReadLine>().WithId("NameInput")
.Then<WriteLine>(x => x.TextExpression = new LiteralExpression("Enter age:"))
.Then<ReadLine>().WithId("AgeInput")
.Then<CreatePerson>(
x =>
{
x.TitleExpression = new JavaScriptExpression<string>("NameInput.Input");
x.AgeExpression = new JavaScriptExpression<int>("AgeInput.Input");
}).WithId("CreatePerson")
.Then<SetVariable>(
x =>
{
x.VariableName = "Person";
x.ValueExpression = new JavaScriptExpression<Person>("CreatePerson.Person");
})
.Then<SetVariable>(
x =>
{
x.VariableName = "Age";
x.ValueExpression = new JavaScriptExpression<int>("CreatePerson.Person.Age");
})
.Then<WriteLine>(x => x.TextExpression = new JavaScriptExpression<string>("`A new person was created with name \"${Person.FullName}\" and age \"${Age}\"`"));
}
}
}