public async Task <BankAccountModel> Deposit(DepositModel model) { var validator = new DepositValidator(_bankAccountRepository); var result = validator.Validate(model); if (!result.IsValid) { throw new Exception(string.Join("; ", result.Errors)); } var account = await _bankAccountRepository.FindAccount(model.AccountNumber); account.Balance += model.Ammount; _bankAccountRepository.Change(account); await _bankAccountRepository.SingleUnit.CommitAsync(); return(_mapper.Map <BankAccountModel>(account)); }
public async Task <bool> ExistingAccount(int AccountNumber, CancellationToken cancellation) { var account = await _bankAccountRepository.FindAccount(AccountNumber); return(account != null); }