Ejemplo n.º 1
0
        public static Accounts GetAccount(int userID)
        {
            var allAccounts = AccountsBL.GetAll(userID);

            foreach (var i in allAccounts)
            {
                if ((i.accountType == "Loan Account") || (i.accountType == "Business Account" && i.balance < 0))
                {
                    Console.WriteLine("{0} - {1} currently owe ${2}", i.accountID, i.accountType, -1 * i.balance);
                }
                else
                {
                    Console.WriteLine("{0} - {1} with a balance of ${2}", i.accountID, i.accountType, i.balance);
                }
            }

            Console.WriteLine("0 - Go Back to Main Menu");

            Console.Write("Please Choose an Account: ");
            int userInput = -1;

            bool cond = true;

            do
            {
                try
                {
                    userInput = Convert.ToInt32(Console.ReadLine());
                    if (userInput == 0)
                    {
                        BankingOptions.MainMenu(userID); cond = true;
                    }
                    if (AccountsBL.Get(userID, userInput) == null)
                    {
                        Console.WriteLine("****Please Choose a Valid Account****");
                    }
                    else
                    {
                        cond = false;
                    }
                }
                catch (FormatException)
                {
                    Console.WriteLine("****Please Choose a Valid Account****");
                }
                catch (NullReferenceException)
                {
                    Console.WriteLine("****Please Choose a Valid Account****");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("A fatal error has been logged. Please try again ");
                }
            } while (cond);

            return(AccountsBL.Get(userID, userInput));
        }
Ejemplo n.º 2
0
        public static void CloseAccount(int userID)
        {
            Console.WriteLine("Select Which Account You Would Like to Close");
            var acc      = GetAccounts.GetAccount(userID);
            var accExist = AccountsBL.CloseAccount(acc.userID, acc.accountID);

            if (accExist == null)
            {
                Console.WriteLine("Your Account Has Successfully Been Closed");
            }
            Console.WriteLine("\nPress <ENTER> to continue...");
            Console.ReadLine();
            Console.Clear();
        }
Ejemplo n.º 3
0
        public static void NewAccount(int userID)
        {
            bool     cond        = true;
            Accounts accountInfo = new Accounts {
                userID = userID
            };

            Console.WriteLine("1 - Checking Account \n2 - Business Account \n3 - Loan Account \n4 - Term Deposit Account \n0 - Main Menu");
            Console.Write("Which type of account would you like to open: ");
            do
            {
                string userInput = Console.ReadLine();
                if (userInput == "1")
                {
                    accountInfo.accountType = "Checking Account";
                    accountInfo.interest    = 1.0005;
                    cond = false;
                }
                else if (userInput == "2")
                {
                    Console.Clear();
                    accountInfo.accountType = "Business Account";
                    do
                    {
                        Console.WriteLine("\nOpening your Business Account...\nPlease choose an interest rate: \n1 - 5% Compounded Annually \n2 - 2.89% Compounded Semi-Annually \n3 - 1.5% Compounded Quarterly");
                        userInput = Console.ReadLine();
                        if (userInput == "1")
                        {
                            accountInfo.interest = 1.025; cond = false;
                        }
                        else if (userInput == "2")
                        {
                            accountInfo.interest = 1.055; cond = false;
                        }
                        else if (userInput == "3")
                        {
                            accountInfo.interest = 1.11; cond = false;
                        }
                        else
                        {
                            Console.Clear(); Console.WriteLine("****Please Make a Valid Choice From the Options Above****\n");
                        }
                    } while (cond);
                }
                else if (userInput == "3")
                {
                    Console.Clear();
                    accountInfo.accountType = "Loan Account";
                    do
                    {
                        Console.WriteLine("Opening your Loan Account...\n1 - $20000 with a 2.5% Annual Rate \n2 - $50000 with a 5.5% Annual Rate \n3 - $100000 with a 11% Annual Rate");
                        Console.Write("\nPlease choose a loan offer: ");
                        userInput = Console.ReadLine();
                        if (userInput == "1")
                        {
                            accountInfo.interest = 1.05;
                            accountInfo.balance  = -20000;
                            cond = false;
                        }
                        else if (userInput == "2")
                        {
                            accountInfo.interest = 1.0289;
                            accountInfo.balance  = -50000;
                            cond = false;
                        }
                        else if (userInput == "3")
                        {
                            accountInfo.interest = 1.015;
                            accountInfo.balance  = -100000;
                            cond = false;
                        }
                        else
                        {
                            Console.Clear();
                            Console.WriteLine("PLEASE MAKE A VALID CHOICE");
                        }
                    } while (cond);
                }
                else if (userInput == "4")
                {
                    Console.Clear();
                    accountInfo.accountType = "Term Deposit Account";
                    do
                    {
                        Console.WriteLine("Opening your Term Deposit Account...\nPlease choose an interest rate: \n1 - 4.5% For 1 Year \n2 - 17.5% For 5 Year \n3 - 25% For 10 Year");
                        userInput = Console.ReadLine();
                        if (userInput == "1")
                        {
                            accountInfo.interest = 1.045; cond = false;
                        }
                        else if (userInput == "2")
                        {
                            accountInfo.interest = 1.175; cond = false;
                        }
                        else if (userInput == "3")
                        {
                            accountInfo.interest = 1.25; cond = false;
                        }
                        else
                        {
                            Console.Clear();  Console.WriteLine("****Please Make a Valid Choice From the Options Above****\n");
                        }

                        Console.Write("\nHow much would you like to deposit into your Term Deposit Account: $");

                        bool   cond2   = true;
                        double deposit = 0;
                        do
                        {
                            try
                            {
                                deposit = Convert.ToDouble(Console.ReadLine());
                                cond2   = false;
                            }
                            catch (FormatException)
                            {
                                Console.Write("\nPlease enter a valid ammount: $");
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine("A fatal error has been logged. Please try again ");
                            }
                        } while (cond2);
                        accountInfo.balance = deposit;
                    } while (cond);
                }
                else if (userInput == "0")
                {
                    BankingOptions.MainMenu(userID);
                }
                else
                {
                    Console.WriteLine("\n****Please Make a Valid Choice From the Options Above ****\n");
                }
            } while (cond);
            Console.WriteLine("\nRegistration Complete! Your {0} is now open and active!", accountInfo.accountType);

            AccountsBL accountBL = new AccountsBL();

            accountBL.CreateABL(accountInfo);

            Console.WriteLine("\nPress <ENTER> to continue...");
            Console.ReadLine();
            Console.Clear();
        }
Ejemplo n.º 4
0
        public static void Deposit(int userID)
        {
            Console.WriteLine("**You Can Deposit Into a Loan Account to Make a Payment**\n");
            var acc = GetAccounts.GetAccount(userID);

            Console.Clear();

            bool cond = true;

            do
            {
                if ((acc.accountType == "Term Deposit Account"))
                {
                    Console.Write("Cannot Deposit Into a {0}. \nPlease Choose a Valid Account: ", acc.accountType);
                    acc = GetAccounts.GetAccount(userID);
                }
                else
                {
                    cond = false;
                }
            } while (cond);

            Console.WriteLine("Depositing to {1} - {0} \nBalance of ${2}\n", acc.accountID, acc.accountType, acc.balance);
            double ammount = 0;

            cond = true;
            bool cond2 = true;

            do
            {
                try
                {
                    do
                    {
                        Console.Write("Deposit Amount: $");
                        ammount = Convert.ToDouble(Console.ReadLine());

                        if (ammount.ToString().Split(".")[1].Length != 2)
                        {
                            Console.WriteLine("****Please Enter a Valid Amount****\n");
                        }
                        else
                        {
                            cond2 = false;
                        }
                    } while (cond2);
                    cond = false;
                }
                catch (FormatException)
                {
                    Console.WriteLine("****Please Enter a Valid Amount****\n");
                }
                catch (IndexOutOfRangeException)
                {
                    cond = false;
                }
                catch (Exception ex)
                {
                    Console.WriteLine("A fatal error has been logged. Please try again\n");
                }
            } while (cond);

            double newBal      = ammount + acc.balance;
            string transaction = "Deposited " + ammount + " into account";

            acc = AccountsBL.UpdateBalance(acc.userID, acc.accountID, newBal);
            acc = AccountsBL.AddTransaction(acc.userID, acc.accountID, transaction);

            Console.WriteLine("\nYour New Balance is $" + newBal);
            Console.WriteLine("\nPress <ENTER> to continue...");
            Console.ReadLine();
            Console.Clear();
        }
Ejemplo n.º 5
0
        public static void Transfer(int userID)
        {
            Console.WriteLine("Which Account Do You Want To Transfer From? \n");
            var  accFrom = GetAccounts.GetAccount(userID);
            bool cond    = true;

            do
            {
                if (accFrom.accountType == "Term Deposit Account" || accFrom.accountType == "Loan Account")
                {
                    Console.WriteLine("\nCannot Transfer From a {0}. \nPlease choose a Valid Account: ", accFrom.accountType);
                    accFrom = GetAccounts.GetAccount(userID);
                }
                else
                {
                    cond = false;
                }
            } while (cond);

            Console.WriteLine("\n**You Can Transfer Into a Loan Account to Make a Payment**");

            double ammount = -1;

            cond = true;
            bool cond2 = true;

            do
            {
                try
                {
                    do
                    {
                        Console.Write("\nAmount You Want to Transfer: $");
                        ammount = Convert.ToDouble(Console.ReadLine());

                        if (ammount.ToString().Split(".")[1].Length != 2)
                        {
                            Console.WriteLine("****Please Enter a Valid Amount****\n");
                        }
                        else
                        {
                            cond2 = false;
                        }
                    } while (cond2);
                    cond = false;
                }
                catch (FormatException)
                {
                    Console.WriteLine("****Please enter a valid ammount****\n");
                }
                catch (IndexOutOfRangeException)
                {
                    cond = false;
                }
                catch (Exception ex)
                {
                    Console.WriteLine("A fatal error has been logged. Please try again ");
                }
            } while (cond);



            cond  = true;
            cond2 = true;
            do
            {
                if (accFrom.accountType == "Checking Account" && (accFrom.balance - ammount) < 0)
                {
                    //This Do While Handles Exceptions
                    do
                    {
                        try
                        {
                            //This Do While Loops Handles The Decimal Places of the Entered Ammount
                            do
                            {
                                Console.Write("\nInsufficient Funds. \nPlease Enter a Valid Ammount: $");
                                ammount = Convert.ToDouble(Console.ReadLine());

                                if (ammount.ToString().Split(".")[1].Length != 2)
                                {
                                    Console.WriteLine("****Please Enter a Valid Amount****\n");
                                }
                                else
                                {
                                    cond2 = false;
                                }
                            } while (cond2);
                            cond = false;
                        }
                        catch (FormatException)
                        {
                            Console.WriteLine("****Please enter a valid ammount****\n");
                        }
                        catch (IndexOutOfRangeException)
                        {
                            cond = false;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("A fatal error has been logged. Please try again ");
                        }
                    } while (cond);
                    cond = true;
                }
                else
                {
                    cond = false;
                }
            } while (cond);

            Console.WriteLine("\nWhich Account Do You Want To Transfer the Money To?\n");
            var accTo = GetAccounts.GetAccount(userID);

            cond = true;
            do
            {
                if (accTo.accountType == "Term Deposit Account")
                {
                    Console.WriteLine("\nCannot Transfer To a {0}. \nPlease choose a Valid Account: ", accTo.accountType);
                    accTo = GetAccounts.GetAccount(userID);
                }
                else
                {
                    cond = false;
                }
            } while (cond);

            Console.WriteLine("\nTransfering {0} From {1}-{2} to {3}-{4}", ammount, accFrom.accountType, accFrom.accountID, accTo.accountType, accTo.accountID);

            //Withdrawing out funds from first account
            double newBal = accFrom.balance - ammount;

            accFrom = AccountsBL.UpdateBalance(accFrom.userID, accFrom.accountID, newBal);
            string transaction = "Transferred " + ammount + " into Account " + accTo.accountID + " from Account " + accFrom.accountID;

            accFrom = AccountsBL.AddTransaction(accFrom.userID, accFrom.accountID, transaction);

            //Depositing funds into second account
            newBal = ammount + accTo.balance;
            accTo  = AccountsBL.UpdateBalance(accTo.userID, accTo.accountID, newBal);
            accTo  = AccountsBL.AddTransaction(accTo.userID, accTo.accountID, transaction);

            Console.WriteLine("Transfer Complete!\n");

            Console.WriteLine("Your New Balance for {0}-{1} is ${2}", accFrom.accountType, accFrom.accountID, accFrom.balance);
            Console.WriteLine("Your New Balance for {0}-{1} is ${2}", accTo.accountType, accTo.accountID, accTo.balance);
            Console.WriteLine("\nPress <ENTER> to continue...");
            Console.ReadLine();
            Console.Clear();
        }
Ejemplo n.º 6
0
        public static void Withdraw(int userID)
        {
            var acc = GetAccounts.GetAccount(userID);

            Console.Clear();

            bool cond = true;

            do
            {
                if ((acc.accountType == "Term Deposit Account") || (acc.accountType == "Loan Account"))
                {
                    Console.Write("Cannot Withdraw From a {0}. \nPlease Choose a Valid Account: ", acc.accountType);
                    acc = GetAccounts.GetAccount(userID);
                }
                else if (acc.accountType == "Business Account" && acc.balance <= -10000)
                {
                    Console.Write("Cannot Withdraw From {0}. Overdraft Limit Reached! \nPlease Choose a Valid Account: ", acc.accountType);
                    acc = GetAccounts.GetAccount(userID);
                }
                else
                {
                    cond = false;
                }
            } while (cond);
            Console.WriteLine("Withdrawing from {1} - {0} \nBalance of ${2}", acc.accountID, acc.accountType, acc.balance);
            double ammount = 0;

            cond = true;
            bool cond2 = true;

            do
            {
                try
                {
                    do
                    {
                        Console.Write("\nWithdraw Amount: $");
                        ammount = Convert.ToDouble(Console.ReadLine());

                        if (ammount.ToString().Split(".")[1].Length != 2)
                        {
                            Console.WriteLine("****Please Enter a Valid Amount****\n");
                        }
                        else
                        {
                            cond2 = false;
                        }
                    } while (cond2);
                    cond = false;
                }
                catch (FormatException)
                {
                    Console.WriteLine("****Please enter a valid ammount****");
                }
                catch (IndexOutOfRangeException)
                {
                    cond = false;
                }
                catch (Exception ex)
                {
                    Console.WriteLine("A fatal error has been logged. Please try again ");
                }
            } while (cond);

            cond = true;
            do
            {
                if ((acc.accountType == "Checking Account" && (acc.balance - ammount) < 0) || (acc.accountType == "Business Account" && (acc.balance - ammount) < -10000))
                {
                    try
                    {
                        Console.Write("\nInsufficient Funds. \nPlease Enter a Valid Ammount: $");
                        ammount = Convert.ToDouble(Console.ReadLine());
                        cond    = false;
                    }
                    catch (FormatException)
                    {
                        Console.WriteLine("****Please enter a valid ammount****\n");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("A fatal error has been logged. Please try again ");
                    }
                }
                else
                {
                    cond = false;
                }
            } while (cond);

            double newBal      = acc.balance - ammount;
            string transaction = "Withdrew " + ammount + " into account";

            acc = AccountsBL.UpdateBalance(acc.userID, acc.accountID, newBal);
            acc = AccountsBL.AddTransaction(acc.userID, acc.accountID, transaction);

            Console.WriteLine("\nYour New Balance is $" + newBal);
            Console.WriteLine("\nPress <ENTER> to continue...");
            Console.ReadLine();
            Console.Clear();
        }