Beispiel #1
0
        public async Task <CurrentAccount> Create(Guid customerId)
        {
            var currentAccount = new CurrentAccount(customerId);

            _currentAccountRepository.Create(currentAccount);

            await _currentAccountRepository.UnitOfWork.Commit();

            return(currentAccount);
        }
Beispiel #2
0
        public async Task ProcessYield(CurrentAccount currentAccount)
        {
            var yield = Math.Round((currentAccount.CurrentBalance * (decimal)TaxCDI), 2);

            var transaction = new Transaction(currentAccount.Id, TransactionType.Yield, yield);

            _currentAccountRepository.CreateTransaction(transaction);

            currentAccount.CurrentBalance += yield;

            _currentAccountRepository.Update(currentAccount);

            await _currentAccountRepository.UnitOfWork.Commit();
        }
Beispiel #3
0
        public async Task <Transaction> Deposit(CurrentAccount currentAccount, decimal amount)
        {
            var transaction = new Transaction(currentAccount.Id, TransactionType.Deposit, amount);

            _currentAccountRepository.CreateTransaction(transaction);

            currentAccount.CurrentBalance += amount;

            _currentAccountRepository.Update(currentAccount);

            await _currentAccountRepository.UnitOfWork.Commit();

            return(transaction);
        }
Beispiel #4
0
        public async Task <Transaction> ToWithdraw(CurrentAccount currentAccount, decimal amount)
        {
            if (amount > currentAccount.CurrentBalance)
            {
                throw new DomainException("Saldo insuficiente!");
            }

            var transaction = new Transaction(currentAccount.Id, TransactionType.Withdrawal, amount);

            _currentAccountRepository.CreateTransaction(transaction);

            currentAccount.CurrentBalance -= amount;

            _currentAccountRepository.Update(currentAccount);

            await _currentAccountRepository.UnitOfWork.Commit();

            return(transaction);
        }
Beispiel #5
0
 public async Task <List <Transaction> > GetListTransaction(CurrentAccount currentAccount)
 {
     return(await _currentAccountRepository.GetListTransactions(currentAccount.Id));
 }