public async Task Deposit(Guid accountId, decimal amount, CancellationToken cancellationToken) { var withdrawAmountCommand = new DepositAmountCommand() { AccountId = accountId, Amount = amount }; await _commandHandler.Handle(withdrawAmountCommand, cancellationToken); }
public void HandleCommand(DepositAmountCommand cmd) { this.logger.Log(string.Format("In {0} command handler", cmd.GetType().Name)); if (cmd != null) { Account acc = this.repository.Get(cmd.AccountId); if (acc != null) { acc.Deposit(cmd.Amount.Currency, cmd.Amount.Value); this.repository.Save(acc); } else { throw new Exception(String.Format("No Account exists with Id {0}", cmd.AccountId)); } } }
public async Task DepositAmount(Guid accountId, decimal amount) { var token = new CancellationToken(); var command = new DepositAmountCommand(accountId, amount); await mediator.Send(command, token); }