Esempio n. 1
0
        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));
        }