コード例 #1
0
 public async Task Deposit(Guid accountId, decimal amount, CancellationToken cancellationToken)
 {
     var withdrawAmountCommand = new DepositAmountCommand()
     {
         AccountId = accountId,
         Amount    = amount
     };
     await _commandHandler.Handle(withdrawAmountCommand, cancellationToken);
 }
コード例 #2
0
        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));
                }
            }
        }
コード例 #3
0
 public async Task DepositAmount(Guid accountId, decimal amount)
 {
     var token   = new CancellationToken();
     var command = new DepositAmountCommand(accountId, amount);
     await mediator.Send(command, token);
 }