/// <summary> /// Create a new account. /// </summary> /// <param name="newType">Type of account to create.</param> /// <param name="currentCustomer">Owing customer.</param> /// <param name="newBalance">Starting balance.</param> /// <returns>Returns a new Account object.</returns> public Account GenerateNewAccount(Utility.AccountType newType, Customer currentCustomer, double newBalance = 0.0) { Account newAccount = null; // Create new account based on specified type. switch (newType) { case Utility.AccountType.CHECKING: newAccount = AddNewCheckingAccount(currentCustomer, newBalance); break; case Utility.AccountType.BUSINESS: newAccount = AddNewBusinessAccount(currentCustomer, newBalance); break; case Utility.AccountType.TERM: newAccount = AddNewTermAccount(currentCustomer, newBalance); break; case Utility.AccountType.LOAN: newAccount = AddNewLoanAccount(currentCustomer, newBalance); break; default: break; } return(newAccount); }
public virtual CustomerAccountsVM GetCustomerAccounts(int customerID, Utility.AccountType accountType) { CustomerAccountsVM result = new CustomerAccountsVM(); try { int accountTypeID = GetAccountTypeID(accountType); result.Customer = myContext.Customers.Where(c => c.ID == customerID).FirstOrDefault(); result.Accounts = myContext.Accounts. Where(a => a.CustomerID == customerID && a.AccountTypeID == accountTypeID && a.IsOpen && a.IsActive).ToList(); // Define each account type name. List <AccountType> allAccountTypes = GetAllAccountTypes(); // Check all accounts for type and deposit/withdrawability. result.AccountType = new List <string>(); result.isDepositable = new System.Collections.BitArray(result.Accounts.Count); result.isWithdrawable = new System.Collections.BitArray(result.Accounts.Count); result.isLoanPayable = new System.Collections.BitArray(result.Accounts.Count); int index = 0; foreach (var item in result.Accounts) { // Set account type name. result.AccountType.Add(allAccountTypes[item.AccountTypeID].Name); // Set flag for deposit account. result.isDepositable.Set(index, IsAccountDepositable(item)); // Set flag for withdraw account. result.isWithdrawable.Set(index, IsAccountWithdrawable(item)); // Set flag for loan payment account. result.isLoanPayable.Set(index, IsLoanAccount(item.AccountTypeID) && item.AccountBalance > 0.0); ++index; } } catch (Exception WTF) { Console.WriteLine(WTF); throw; } finally { } return(result); }
/// <summary> /// Remove specific account from storage. /// </summary> /// <param name="currentCustomer">Owning customer.</param> /// <param name="currentAccountType">Type of Account.</param> /// <param name="currentAccount">Account reference object.</param> /// <param name="accountIndex">Index of account object.</param> /// <returns>Returns, True if removal was successfull. Otherwise, False.</returns> private bool RemoveSpecificAccount(Customer currentCustomer, Utility.AccountType currentAccountType, Account currentAccount, int accountIndex) { bool result = false; // Remove account from current customer. if (currentCustomer != null) { result = currentCustomer.RemoveAccount(currentAccount); } // Remove account from specific account type list and index. allAccounts[currentAccountType].RemoveAt(accountIndex); return(true); }
public int GetAccountTypeID(Utility.AccountType accountType) { int result = -1; try { AccountType tempType = null; switch (accountType) { case Utility.AccountType.CHECKING: tempType = myContext.AccountTypes.Where(t => t.Name == "Checking").FirstOrDefault(); break; case Utility.AccountType.BUSINESS: tempType = myContext.AccountTypes.Where(t => t.Name == "Business").FirstOrDefault(); break; case Utility.AccountType.TERM_DEPOSIT: tempType = myContext.AccountTypes.Where(t => t.Name == "Term CD").FirstOrDefault(); break; case Utility.AccountType.LOAN: tempType = myContext.AccountTypes.Where(t => t.Name == "Loan").FirstOrDefault(); break; case Utility.AccountType._COUNT: break; default: throw new Exception("INVALID ACCOUNT TYPE SELECTED!"); } if (tempType != null) { result = tempType.ID; } } catch (Exception WTF) { Console.WriteLine(WTF); throw; } return(result); }
public override CustomerAccountsVM GetCustomerAccounts(int customerID, Utility.AccountType accountType) { return(base.GetCustomerAccounts(customerID, accountType)); }
public void DisplayAllCustomerAccountsByType(Utility.AccountType currentAccountType, Account[] allAccountsByType) { int accountNumber = 0; double currentBalance = 0.0; switch (currentAccountType) { case Utility.AccountType.CHECKING: Console.WriteLine("---Checking Accounts---"); break; case Utility.AccountType.BUSINESS: Console.WriteLine("---Business Accounts---"); break; case Utility.AccountType.TERM: Console.WriteLine("---CD Term Accounts---"); break; case Utility.AccountType.LOAN: Console.WriteLine("---Loan Accounts---"); break; default: // Invalid Account Type. // Break from function. return; } Console.WriteLine("Account #\t:\tAccount Balance"); foreach (IAccountInfo item in allAccountsByType) { accountNumber = item.AccountNumber; // Check for type of account. switch (currentAccountType) { case Utility.AccountType.CHECKING: currentBalance = item.AccountBalance; break; case Utility.AccountType.BUSINESS: currentBalance = item.AccountBalance; break; case Utility.AccountType.TERM: currentBalance = item.AccountBalance; break; case Utility.AccountType.LOAN: currentBalance = item.AccountBalance; break; default: break; } // Display this account. Console.WriteLine("{0,9}\t \t{1,15}", accountNumber.ToString("D1"), currentBalance.ToString("C2")); } Console.WriteLine(); }
public CustomerAccountsVM GetCustomerAccounts(int customerID, Utility.AccountType accountType) { throw new NotImplementedException(); }
public int GetAccountTypeID(Utility.AccountType accountType) { throw new NotImplementedException(); }