Beispiel #1
0
        /// <summary>
        /// Remove business account from storage.
        /// </summary>
        /// <param name="newAccount">BusinessAccount object reference to remove.</param>
        /// <returns>Returns, True if the referenced account was in storage. Otherwise, False.</returns>
        public bool RemoveBusinessAccount(BusinessAccount newAccount)
        {
            bool result = false;

            // Get list index of reference account.
            int accountIndex = allAccounts[Utility.AccountType.BUSINESS].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.
                }
                else if (newAccount.AccountBalance < 0.0)
                {
                    // Run account close overdraft confirmation.
                }

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

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// Generate new BusinessAccount object.
        /// </summary>
        /// <param name="currentCustomer">Owing customer.</param>
        /// <param name="newBalance">Starting balance.</param>
        /// <returns>Returns a new BusinessAccount object.</returns>
        private Account AddNewBusinessAccount(Customer currentCustomer, double newBalance = 0.0)
        {
            Account newAccount = null;

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

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

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

            return(newAccount);
        }
Beispiel #3
0
        /// <summary>
        /// Get business account by account ID number.
        /// </summary>
        /// <param name="accountNumber">ID number of specific account.</param>
        /// <returns>Returns BusinessAccount object of specified account ID.</returns>
        public BusinessAccount GetBusinessAccount(int accountNumber)
        {
            BusinessAccount result = null;

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

            return(result);
        }