-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathExecution.cs
35 lines (26 loc) · 1.03 KB
/
Execution.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
using MediatorPattern.Command;
using MediatorPattern.Query;
using MediatR;
namespace MediatorPattern;
public class Execution
{
private readonly IMediator _mediator;
public Execution(IMediator mediator)
{
_mediator = mediator;
}
public async Task RunAsync()
{
ColorConsole.WriteLineProgram("Creating a new user with name 'Steven'");
var user = await _mediator.Send(new AddNewUserCommand { Name = "Steven" });
ColorConsole.WriteLineProgram($"User has id: {user.Id}");
Console.WriteLine();
ColorConsole.WriteLineProgram($"Get count of users with name 'Rebecca'");
var count = await _mediator.Send(new GetUserCountQuery { NameFilter = "Rebecca" });
ColorConsole.WriteLineProgram($"Found {count} entries");
Console.WriteLine();
ColorConsole.WriteLineProgram($"Deleting all users");
await _mediator.Send(new DeleteAllUsersCommand());
ColorConsole.WriteLineProgram($"All users deleted");
}
}