This commit is contained in:
David Lebee
2021-02-02 12:19:59 -05:00
parent b9fbe5aca1
commit 20df5ce79d
16 changed files with 220 additions and 15 deletions
+33
View File
@@ -0,0 +1,33 @@
using FluentValidation;
using PoweredSoft.CQRS.Abstractions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Demo.Commands
{
public class CreatePersonCommand
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
public class CreatePersonCommandValidator : AbstractValidator<CreatePersonCommand>
{
public CreatePersonCommandValidator()
{
RuleFor(t => t.FirstName).NotEmpty();
RuleFor(t => t.LastName).NotEmpty();
}
}
public class CreatePersonCommandHandler : ICommandHandler<CreatePersonCommand>
{
public Task HandleAsync(CreatePersonCommand command, CancellationToken cancellationToken = default)
{
return Task.CompletedTask;
}
}
}
+31
View File
@@ -0,0 +1,31 @@
using FluentValidation;
using PoweredSoft.CQRS.Abstractions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Demo.Commands
{
public class EchoCommand
{
public string Message { get; set; }
}
public class EchoCommandValidator : AbstractValidator<EchoCommand>
{
public EchoCommandValidator()
{
RuleFor(t => t.Message).NotEmpty();
}
}
public class EchoCommandHandler : ICommandHandler<EchoCommand, string>
{
public Task<string> HandleAsync(EchoCommand command, CancellationToken cancellationToken = default)
{
return Task.FromResult(command.Message);
}
}
}