public async Task <CreateTransactionResponse> ExecuteCommandAsync(AccountDepositCommand command) { if (command == null) { throw new ArgumentNullException(nameof(command)); } var account = await _accountRepository.GetAccountAsync(command.AccountId); if (account == null) { throw new ResourceNotFoundException( "Accounts", $"No account with id {command.AccountId} was found."); } var newTransaction = new Transaction(account, Transaction.DepositTransactionType, command.Amount); var saved = await _transactionRepository.AddNewTransactionAsync(newTransaction); if (saved == false) { throw new CommandProcessingException("Could not save transaction"); } return(new CreateTransactionResponse(newTransaction.TransactionId)); }