-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathSignupFlow.cs
More file actions
35 lines (26 loc) · 1.21 KB
/
Copy pathSignupFlow.cs
File metadata and controls
35 lines (26 loc) · 1.21 KB
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
namespace Cleipnir.Flows.Sample.Presentation.E_CustomerSignup.Solution;
public class SignupFlow : Flow<string>
{
public override async Task Run(string customerEmail)
{
await Effect.Capture(() => SendActivationMail(customerEmail));
for (var i = 0; i <= 3; i++)
{
var emailVerified = await Message<EmailVerified>(waitFor: TimeSpan.FromDays(1));
if (emailVerified != null)
break;
if (i == 3)
throw new UserSignupFailedException($"User '{customerEmail}' did not activate email within threshold");
await Effect.Capture(() => SendReminderMail(customerEmail));
}
await Effect.Capture(() => SendWelcomeMail(customerEmail));
}
private static Task SendActivationMail(string customerEmail) => Task.CompletedTask;
private static Task SendReminderMail(string customerEmail) => Task.CompletedTask;
private static Task SendWelcomeMail(string customerEmail) => Task.CompletedTask;
public class UserSignupFailedException : Exception
{
public UserSignupFailedException(string? message) : base(message) { }
}
public record EmailVerified(string EmailAddress);
}