Ejemplo n.º 1
0
        /// <summary>
        /// Generate new TermDepositAccount object.
        /// </summary>
        /// <param name="currentCustomer">Owing customer.</param>
        /// <param name="newBalance">Starting balance.</param>
        /// <returns>Returns a new TermDepositAccount object.</returns>
        private Account AddNewTermAccount(Customer currentCustomer, double newBalance = 0.0)
        {
            Account newAccount = null;

            // Generate new account data.
            AccountData newData = GenerateNewAccountData();

            // Create new checking account.
            newAccount = new TermDepositAccount(currentCustomer, newData, newBalance);

            // Add new checking account to master list inside dictionary.
            allAccounts[Utility.AccountType.TERM].Add(newAccount);

            return(newAccount);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get term account by account ID number.
        /// </summary>
        /// <param name="accountNumber">ID number of specific account.</param>
        /// <returns>Returns TermDepositAccount object of specified account ID.</returns>
        public TermDepositAccount GetTermAccount(int accountNumber)
        {
            TermDepositAccount result = null;

            // Loop through each account in the list to find the specific account number.
            foreach (TermDepositAccount accountRecord in allAccounts[Utility.AccountType.TERM])
            {
                if (accountRecord.AccountNumber == accountNumber)
                {
                    result = accountRecord;
                    break;
                }
            }

            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Remove term account from storage.
        /// </summary>
        /// <param name="newAccount">TermDepositAccount object reference to remove.</param>
        /// <returns>Returns, True if the referenced account was in storage. Otherwise, False.</returns>
        public bool RemoveTermAccount(TermDepositAccount newAccount)
        {
            bool result = false;

            // Get list index of reference account.
            int accountIndex = allAccounts[Utility.AccountType.TERM].IndexOf(newAccount);

            // Check if a good index was returned.
            if (accountIndex > -1)
            {
                Customer currentCustomer = newAccount.Customer;

                // Check if current account has remaining balance.
                if (newAccount.AccountBalance > 0.0)
                {
                    // Run account close confirmation.
                }

                // Remove all relation to this account object.
                result = RemoveSpecificAccount(currentCustomer, Utility.AccountType.TERM, newAccount, accountIndex);
            }

            return(result);
        }