Пример #1
0
        public void Deposit(DepositRequest depositRequest)
        {
            BankAccount bankAccount = _bankRepository.Find(depositRequest.AccountId);

            bankAccount.Deposit(depositRequest.Amount, "");
            _bankRepository.Save(bankAccount);
        }
Пример #2
0
        public Transaction Deposit(Transaction transaction)
        {
            var bankAccount = _bankAccountRepository.Find(transaction.BankAccountId);

            if (bankAccount != null)
            {
                bankAccount.Balance += transaction.Amount;
            }

            _transactionRepository.Add(transaction);
            _bankAccountRepository.Update(bankAccount);

            return(transaction);
        }
        public void Transfer(Guid accountNoTo, Guid accountNoFrom, decimal amount)
        {
            BankAccount bankAccountTo   = _bankAccountRepository.Find(accountNoTo);
            BankAccount bankAccountFrom = _bankAccountRepository.Find(accountNoFrom);

            if (bankAccountFrom.CanWithdraw(amount))
            {
                bankAccountFrom.Withdraw(amount, "Transfer to acc " + bankAccountTo.CustomerRef);
                bankAccountTo.Deposit(amount, "Transfer from acc " + bankAccountFrom.CustomerRef);

                _bankAccountRepository.Save(bankAccountTo);
                _bankAccountRepository.Save(bankAccountFrom);
            }
            else
            {
                throw new InsufficientFundsException();
            }
        }
Пример #4
0
        public async Task Handle(DebitAccount command)
        {
            this.log.Information($"Handling withdraw command for account {command.BankAccountId}");

            var bankAccount = await bankAccountRepository.Find(command.BankAccountId);

            bankAccount.Withdraw(command.Amount);

            await bankAccountRepository.AddOrUpdate(bankAccount);

            this.log.Information($"Withdrawed amount ${command.Amount} from bank account {command.BankAccountId}");
        }
Пример #5
0
        public async Task Handle(CreditAccount command)
        {
            this.log.Information($"Handling deposit money command for account {command.BankAccountId}");

            var bankAccount = await bankAccountRepository.Find(command.BankAccountId);

            bankAccount.Deposit(command.Amount);

            await bankAccountRepository.AddOrUpdate(bankAccount);

            this.log.Information($"Deposited amount ${command.Amount} into bank account {command.BankAccountId}");
        }
Пример #6
0
 public IList <Bank_Account> GetBankAccounts(string Keyword, string BankAccount, string BankName, string Owner, bool Active, Sorts sorts, Paging paging)
 {
     return(bankAccountRepository.Find(new BankAccountGetBy(Keyword, BankAccount, BankName, Owner, Active), sorts, paging).ToList());
 }