diff --git a/Samples.sln b/Samples.sln
index abf6b959b..10b60aaed 100644
--- a/Samples.sln
+++ b/Samples.sln
@@ -104,6 +104,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.WhileLoopConso
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.WhileLoopWorker", "src\samples\Elsa.Samples.WhileLoopWorker\Elsa.Samples.WhileLoopWorker.csproj", "{85A70E7C-A4AC-49BA-942B-635F974DE255}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.IfElseConsole", "src\samples\Elsa.Samples.IfElseConsole\Elsa.Samples.IfElseConsole.csproj", "{E508C1B6-916F-40F4-8731-58279B8F45B2}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -243,6 +245,10 @@ Global
{85A70E7C-A4AC-49BA-942B-635F974DE255}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85A70E7C-A4AC-49BA-942B-635F974DE255}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85A70E7C-A4AC-49BA-942B-635F974DE255}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E508C1B6-916F-40F4-8731-58279B8F45B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E508C1B6-916F-40F4-8731-58279B8F45B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E508C1B6-916F-40F4-8731-58279B8F45B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E508C1B6-916F-40F4-8731-58279B8F45B2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -291,6 +297,7 @@ Global
{E4485289-F1DF-4322-B07D-9A0C9B002D31} = {5E5E1E84-DDBC-40D6-B891-0D563A15A44A}
{6B83CCE1-D523-4E3F-84EB-8D79AAF6F7C2} = {5E5E1E84-DDBC-40D6-B891-0D563A15A44A}
{85A70E7C-A4AC-49BA-942B-635F974DE255} = {5E5E1E84-DDBC-40D6-B891-0D563A15A44A}
+ {E508C1B6-916F-40F4-8731-58279B8F45B2} = {5E5E1E84-DDBC-40D6-B891-0D563A15A44A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8B0975FD-7050-48B0-88C5-48C33378E158}
diff --git a/src/samples/Elsa.Samples.IfElseConsole/Elsa.Samples.IfElseConsole.csproj b/src/samples/Elsa.Samples.IfElseConsole/Elsa.Samples.IfElseConsole.csproj
new file mode 100644
index 000000000..910f7f606
--- /dev/null
+++ b/src/samples/Elsa.Samples.IfElseConsole/Elsa.Samples.IfElseConsole.csproj
@@ -0,0 +1,17 @@
+
+
+
+ Exe
+ netcoreapp3.1
+ enable
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/samples/Elsa.Samples.IfElseConsole/HappinessWorkflow.cs b/src/samples/Elsa.Samples.IfElseConsole/HappinessWorkflow.cs
new file mode 100644
index 000000000..ea1fb65db
--- /dev/null
+++ b/src/samples/Elsa.Samples.IfElseConsole/HappinessWorkflow.cs
@@ -0,0 +1,66 @@
+using System;
+using Elsa.Activities.Console;
+using Elsa.Activities.ControlFlow;
+using Elsa.Builders;
+using Elsa.Services.Models;
+
+namespace Elsa.Samples.IfElseConsole
+{
+ public class HappinessWorkflow : IWorkflow
+ {
+ private readonly Random _random;
+
+ public HappinessWorkflow()
+ {
+ _random = new Random();
+ }
+
+ public void Build(IWorkflowBuilder workflow)
+ {
+ workflow
+ .WriteLine("--POND OF HAPPINESS--", "Start")
+ .WriteLine("Throw some Rupees in and your wishes will surely come true.")
+ .WriteLine("Do you want to throw Rupees?")
+ .ReadLine()
+ .IfElse(
+ activity => activity.WithCondition(context => IsYes(context.Input)),
+ ifElse =>
+ {
+ ifElse
+ .When(IfElse.True)
+ .WriteLine(GetCurse)
+ .WriteLine("...")
+ .Then("Start");
+
+ ifElse
+ .When(IfElse.False)
+ .WriteLine("Bye.");
+ });
+ }
+
+ private static bool IsYes(object? value)
+ {
+ var text = ((string)value!).ToLowerInvariant();
+ return text switch
+ {
+ "yes" => true,
+ "y" => true,
+ "sure" => true,
+ _ => false
+ };
+ }
+
+ private string GetCurse()
+ {
+ var curses = new[]
+ {
+ "Today, you will have Great Luck",
+ "Today, you will have a Little Luck",
+ "Today, you will have a Big Trouble"
+ };
+
+ var index = _random.Next(0, 3);
+ return curses[index];
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/samples/Elsa.Samples.IfElseConsole/Program.cs b/src/samples/Elsa.Samples.IfElseConsole/Program.cs
new file mode 100644
index 000000000..89134eb59
--- /dev/null
+++ b/src/samples/Elsa.Samples.IfElseConsole/Program.cs
@@ -0,0 +1,32 @@
+using System.Threading.Tasks;
+using Elsa.Services;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace Elsa.Samples.IfElseConsole
+{
+ ///
+ /// Demonstrates a workflow with a While looping construct.
+ ///
+ static class Program
+ {
+ private static async Task Main()
+ {
+ // Create a service container with Elsa services.
+ var services = new ServiceCollection()
+ .AddElsa()
+ .AddConsoleActivities()
+ .AddWorkflow()
+ .BuildServiceProvider();
+
+ // Run startup actions (not needed when registering Elsa with a Host).
+ var startupRunner = services.GetRequiredService();
+ await startupRunner.StartupAsync();
+
+ // Get a workflow runner.
+ var workflowRunner = services.GetService();
+
+ // Execute the workflow.
+ await workflowRunner.RunWorkflowAsync();
+ }
+ }
+}
\ No newline at end of file