public async Task <bool> WithdrawAmmount(int accountId, decimal ammount)
        {
            var account = await checkingAccountRepository.GetAccountById(accountId);

            if (account == null)
            {
                throw new AccountNotFoundException("Source account id not found.");
            }

            account.Withdraw(ammount);

            var transaction = new Transaction(account.AccountId, (Math.Abs(ammount) * (-1)));

            transaction.InformCurrentBalance(account.CurrentBalance);

            account.AddTransaction(transaction);
            await checkingAccountRepository.Update(account);

            return(true);
        }
Example #2
0
        public bool Update(CheckingAccountUpdateCommand cmd)
        {
            var accountDb = _checkingAccountRepository.GetById(cmd.Id) ?? throw new NotFoundException();

            var account = Mapper.Map(cmd, accountDb);

            return(_checkingAccountRepository.Update(account));
        }
Example #3
0
        public bool Update(CheckingAccount checkingAccount)
        {
            var accountDb = _checkingAccountRepository.GetById(checkingAccount.Id) ?? throw new NotFoundException();

            //a linha que tirou nosso 10 /:
            var clientdb = _clientRepository.GetById(checkingAccount.Client.Id) ?? throw new NotFoundException();

            accountDb.Balance      = checkingAccount.Balance;
            accountDb.Client       = clientdb;
            accountDb.Limit        = checkingAccount.Limit;
            accountDb.Transactions = checkingAccount.Transactions;

            return(_checkingAccountRepository.Update(accountDb));
        }
Example #4
0
 /// <summary>
 /// Update an Account Properties
 /// </summary>
 /// <param name="obj">Checking Account data</param>
 /// <returns>Return a Cheking Account object</returns>
 public CheckingAccount Update(CheckingAccount obj)
 {
     _repository.Update(obj);
     return(obj);
 }