public async Task HandleAsync(WithdrawMoney command) { var account = await aggregateStore.LoadAsync <Account>(command.AccountId); if (account == null) { throw new AccountNotExistsException(command.AccountId); } account.Withdraw(command.Amount); await aggregateStore.AppendChangesAsync(account); }
public async Task HandleAsync(CreateAccount command) { var account = await aggregateStore.LoadAsync <Account>(command.AccountId); if (account != null) { throw new AccountAlreadyExistsException(command.AccountId); } var newAccount = Account.Create(command.AccountId); await aggregateStore.AppendChangesAsync(newAccount); }