Exemple #1
0
        public void Deposit(int accountNo, decimal amount, Currency currency, decimal accountExchangeRate)
        {
            if (!CurrencyID.Equals(currency.CurrencyID))
            {
                amount = AppHelper.AppHelper.CalculateAmountWithRates(amount, accountExchangeRate, currency.ExchangeRate);
            }

            var transaction = new Transaction(accountNo, amount, currency, TransactionType.DEPOSIT);

            this.Transactions.Add(transaction);
            Balance += amount;
        }
Exemple #2
0
        public void Withdraw(int accountNo, decimal amount, Currency currency, decimal accountExchangeRate)
        {
            if (!CurrencyID.Equals(currency.CurrencyID))
            {
                amount = AppHelper.AppHelper.CalculateAmountWithRates(amount, accountExchangeRate, currency.ExchangeRate);
            }

            if (amount > Balance)
            {
                throw new InsufficientBalanceException("The amount to withdraw cannot be greater than your account balance!");
            }

            var transaction = new Transaction(accountNo, amount, currency, TransactionType.WITHDRAWAL);

            Transactions.Add(transaction);
            Balance -= amount;
        }