Beispiel #1
0
        /// <summary>
        /// Close account if it exists.
        /// </summary>
        public void CloseBankAccount(BankAccount account)
        {
            CheckAccount(account);
            var bankAccount = _storage.GetAccount(account.Number);

            if (bankAccount != null)
            {
                bankAccount.State = AccountState.Closed;
            }
            else
            {
                throw new Exception("Our storage doesn't have this account.");
            }
        }
        /// <summary>
        /// Makes a deposit of <paramref name="amount"/> to an account with specified <paramref name="iban"/>.
        /// </summary>
        /// <param name="iban">IBAN of an account to make deposit</param>
        /// <param name="amount">deposit amount</param>
        /// <returns>new account balance</returns>
        /// <exception cref="ArgumentException">deposit amount is lesser than minimal</exception>
        public decimal MakeDeposit(string iban, decimal amount)
        {
            if (string.IsNullOrWhiteSpace(iban))
            {
                throw new ArgumentException("No IBAN is given.", "IBAN");
            }

            if (amount < MINDEPOSIT)
            {
                throw new ArgumentException("Minimum deposit amount is " + MINDEPOSIT.ToString("C"));
            }

            var account = storage.GetAccount(iban);

            account.Balance     += amount;
            account.BonusPoints += calculator.CalculateDepositPoints(account, amount);
            storage.SaveAccount(account);

            return(account.Balance);
        }