Add sample workflow with IfElse activity
This commit is contained in:
parent
599c6a5cd6
commit
a1c1ee9ce0
|
|
@ -44,6 +44,7 @@ namespace Elsa.Server.Host
|
|||
.AddWorkflow<HelloWorldV2>()
|
||||
.AddWorkflow<GoodbyeWorld>()
|
||||
.AddWorkflow<NamingWorkflow>()
|
||||
.AddWorkflow<ConditionWorkflow>()
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
|||
24
src/server/Elsa.Server.Host/Workflows/ConditionWorkflow.cs
Normal file
24
src/server/Elsa.Server.Host/Workflows/ConditionWorkflow.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using Elsa.Activities.Console;
|
||||
using Elsa.Activities.ControlFlow;
|
||||
using Elsa.Activities.Primitives;
|
||||
using Elsa.Builders;
|
||||
|
||||
namespace Elsa.Server.Host.Workflows
|
||||
{
|
||||
public class ConditionWorkflow : IWorkflow
|
||||
{
|
||||
public void Build(IWorkflowBuilder workflow)
|
||||
{
|
||||
workflow
|
||||
.WithDisplayName("Conditions")
|
||||
.WriteLine("What is your age?")
|
||||
.ReadLine()
|
||||
.SetVariable("Age", context => int.Parse(context.GetInput<string>()))
|
||||
.IfElse(context => context.GetVariable<int>("Age") < 18, ifElse =>
|
||||
{
|
||||
ifElse.When(OutcomeNames.True).WriteLine("You are not allowed to drink beer.");
|
||||
ifElse.When(OutcomeNames.False).WriteLine("Enjoy your beer!");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue