68 lines
1.9 KiB
C#
68 lines
1.9 KiB
C#
|
|
using Books.Api.Domain.Accounts;
|
||
|
|
using EventFlow.Commands;
|
||
|
|
|
||
|
|
namespace Books.Api.Commands.Accounts;
|
||
|
|
|
||
|
|
public class CreateAccountCommandHandler : CommandHandler<AccountAggregate, AccountId, CreateAccountCommand>
|
||
|
|
{
|
||
|
|
public override Task ExecuteAsync(
|
||
|
|
AccountAggregate aggregate,
|
||
|
|
CreateAccountCommand command,
|
||
|
|
CancellationToken cancellationToken)
|
||
|
|
{
|
||
|
|
aggregate.Create(
|
||
|
|
command.CompanyId,
|
||
|
|
command.AccountNumber,
|
||
|
|
command.Name,
|
||
|
|
command.AccountType,
|
||
|
|
command.ParentId,
|
||
|
|
command.Description,
|
||
|
|
command.VatCodeId,
|
||
|
|
command.IsSystemAccount,
|
||
|
|
command.StandardAccountNumber);
|
||
|
|
|
||
|
|
return Task.CompletedTask;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public class UpdateAccountCommandHandler : CommandHandler<AccountAggregate, AccountId, UpdateAccountCommand>
|
||
|
|
{
|
||
|
|
public override Task ExecuteAsync(
|
||
|
|
AccountAggregate aggregate,
|
||
|
|
UpdateAccountCommand command,
|
||
|
|
CancellationToken cancellationToken)
|
||
|
|
{
|
||
|
|
aggregate.Update(
|
||
|
|
command.Name,
|
||
|
|
command.ParentId,
|
||
|
|
command.Description,
|
||
|
|
command.VatCodeId);
|
||
|
|
|
||
|
|
return Task.CompletedTask;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public class DeactivateAccountCommandHandler : CommandHandler<AccountAggregate, AccountId, DeactivateAccountCommand>
|
||
|
|
{
|
||
|
|
public override Task ExecuteAsync(
|
||
|
|
AccountAggregate aggregate,
|
||
|
|
DeactivateAccountCommand command,
|
||
|
|
CancellationToken cancellationToken)
|
||
|
|
{
|
||
|
|
aggregate.Deactivate();
|
||
|
|
return Task.CompletedTask;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public class ReactivateAccountCommandHandler : CommandHandler<AccountAggregate, AccountId, ReactivateAccountCommand>
|
||
|
|
{
|
||
|
|
public override Task ExecuteAsync(
|
||
|
|
AccountAggregate aggregate,
|
||
|
|
ReactivateAccountCommand command,
|
||
|
|
CancellationToken cancellationToken)
|
||
|
|
{
|
||
|
|
aggregate.Reactivate();
|
||
|
|
return Task.CompletedTask;
|
||
|
|
}
|
||
|
|
}
|