Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //Add Default User
            TheBanc.AddDefaultUser();

            //Set Window and Console
            UIHelpers.SetWindow();
            UIHelpers.ConsoleSetup();
            UIHelpers.Clear();

            ////Get a user or stay at login screen
            do
            {
                currentUser = LoginOrRegister(currentUser);
            }while (currentUser == null);


            //Keeps Console Open - Unsure if really needed
            //Testing indicates not needed, but leaving it just in case
            //Console.ReadLine();
        }
Ejemplo n.º 2
0
        //Method for displaying account balance
        public static Account CheckAccountBalance(Account userMakingTransaction)
        {
            //Layout for balance display
            UIHelpers.Clear();
            Console.WriteLine("\t==================================================");
            Console.WriteLine("\tAccount Balance");
            Console.WriteLine("\t==================================================");
            Console.WriteLine("\tAccount Owner:    \t{0} {1}", userMakingTransaction.CustomerPersonalInformation.FirstName, userMakingTransaction.CustomerPersonalInformation.LastName);
            Console.WriteLine("\tAccount Number:   \t{0}", userMakingTransaction.CustomerFinancialInformation.AccountNumber);
            Console.WriteLine("\tAccount Type:     \t{0}\n", userMakingTransaction.CustomerFinancialInformation.AccountType);
            Console.WriteLine("\tDate:             \t{0}", DateTime.Now);
            Console.WriteLine("\t==================================================");
            Console.WriteLine("\n");

            //Actual get of balance
            Console.WriteLine("\tAvailable Balance:\t{0:C}", userMakingTransaction.CustomerFinancialInformation.AccountBalance);

            //Return to main menu
            Console.WriteLine("\n");
            Console.Write("\tPress 'Spacebar' to return to the account menu.");
            if (Console.ReadKey().Key == ConsoleKey.Spacebar)
                AccountMainMenu(userMakingTransaction);
            return userMakingTransaction;
        }
Ejemplo n.º 3
0
        //Method for registering a new user
        //Returns user coming back from main menu after success to LoginOrRegister
        public static Account Register(RegistrationEnum currentRegistrationField)
        {
            string label = currentRegistrationField.GetDescription();

            switch (currentRegistrationField)
            {
            case RegistrationEnum.RegisterEmail:

                //string label = "Email Address";
                Console.Write("\n\tWhat is your " + label + "? ");

                var regEmail = Console.ReadLine().Trim();

                //Check to see if email already exists
                if (TheBanc.UserAccounts.Exists(i => i.AccountEmailAddressAndUsername == regEmail))
                {
                    UIHelpers.WarningColor();
                    Console.Write("\n\tThe Email Address '" + regEmail + "' already exists.\n\tDo you want to login instead? (Y\\N) ");
                    ConsoleKey loginInstead = Console.ReadKey().Key;
                    Console.Write("\x1B[1D" + "\x1B[1P" + loginInstead.ToString().ToUpper());

                    if (loginInstead == ConsoleKey.Y)
                    {
                        UIHelpers.ResetColor();
                        Console.WriteLine("\n");
                        LoginController.LoginEmail(loginAttempts);
                    }
                    else
                    {
                        UIHelpers.ResetColor();
                        Register(currentRegistrationField);
                    }
                }
                else
                {
                    newAccountBeingCreated = new Account();

                    newAccountBeingCreated.AccountEmailAddressAndUsername = regEmail;

                    if (VerifyInput(regEmail, label))
                    {
                        Register(++currentRegistrationField);
                    }
                    else
                    {
                        Register(currentRegistrationField);
                    }
                }
                break;

            case RegistrationEnum.RegisterFirstName:

                Console.Write("\n\tWhat is your " + label + "? ");

                newAccountBeingCreated.CustomerPersonalInformation.FirstName = UppercaseFirst(Console.ReadLine());

                if (VerifyInput(newAccountBeingCreated.CustomerPersonalInformation.FirstName, label))
                {
                    Register(++currentRegistrationField);
                }
                else
                {
                    Register(currentRegistrationField);
                }
                break;

            case RegistrationEnum.RegisterLastName:

                Console.Write("\n\tWhat is your " + label + "? ");

                newAccountBeingCreated.CustomerPersonalInformation.LastName = UppercaseFirst(Console.ReadLine());

                if (VerifyInput(newAccountBeingCreated.CustomerPersonalInformation.LastName, label))
                {
                    Register(++currentRegistrationField);
                }
                else
                {
                    Register(currentRegistrationField);
                }
                break;

            case RegistrationEnum.RegisterAddress:

                Console.Write("\n\tWhat is your Street " + label + "? ");

                newAccountBeingCreated.CustomerPersonalInformation.Address = Console.ReadLine();

                if (VerifyInput(newAccountBeingCreated.CustomerPersonalInformation.Address, label))
                {
                    Register(++currentRegistrationField);
                }
                else
                {
                    Register(currentRegistrationField);
                }
                break;

            case RegistrationEnum.RegisterCity:

                Console.Write("\n\tWhat is your " + label + "? ");

                newAccountBeingCreated.CustomerPersonalInformation.City = UppercaseFirst(Console.ReadLine());

                if (VerifyInput(newAccountBeingCreated.CustomerPersonalInformation.City, label))
                {
                    Register(++currentRegistrationField);
                }
                else
                {
                    Register(currentRegistrationField);
                }
                break;

            case RegistrationEnum.RegisterState:

                Console.Write("\n\tWhat is your " + label + "? (Example: OR) ");

                newAccountBeingCreated.CustomerPersonalInformation.State = Console.ReadLine().ToUpper();

                if (VerifyInput(newAccountBeingCreated.CustomerPersonalInformation.State, label))
                {
                    Register(++currentRegistrationField);
                }
                else
                {
                    Register(currentRegistrationField);
                }
                break;

            case RegistrationEnum.RegisterZipcode:

                Console.Write("\n\tWhat is your " + label + "? ");

                newAccountBeingCreated.CustomerPersonalInformation.Zipcode = Console.ReadLine();

                if (VerifyInput(newAccountBeingCreated.CustomerPersonalInformation.Zipcode, label))
                {
                    Register(++currentRegistrationField);
                }
                else
                {
                    Register(currentRegistrationField);
                }
                break;

            case RegistrationEnum.RegisterPhoneNumber:

                Console.Write("\n\tWhat is your " + label + "? ");

                string regPhoneTemp = Console.ReadLine();
                newAccountBeingCreated.CustomerPersonalInformation.PhoneNumber = phoneNumberHelper(regPhoneTemp);

                if (VerifyInput(newAccountBeingCreated.CustomerPersonalInformation.PhoneNumber, label))
                {
                    Register(++currentRegistrationField);
                }
                else
                {
                    Register(currentRegistrationField);
                }
                break;

            case RegistrationEnum.RegistrationFinalVerification:

                UIHelpers.Clear();

                Console.WriteLine("\n\tGreat. Let's verify the information...\n");
                UIHelpers.WarningColor();
                Console.WriteLine("\tFirst Name: " + newAccountBeingCreated.CustomerPersonalInformation.FirstName);
                Console.WriteLine("\tLast Name:  " + newAccountBeingCreated.CustomerPersonalInformation.LastName);
                Console.WriteLine("\tAddress:    " + newAccountBeingCreated.CustomerPersonalInformation.Address);
                Console.WriteLine("\tCity:       " + newAccountBeingCreated.CustomerPersonalInformation.City);
                Console.WriteLine("\tState:      " + newAccountBeingCreated.CustomerPersonalInformation.State);
                Console.WriteLine("\tZipcode:    " + newAccountBeingCreated.CustomerPersonalInformation.Zipcode);
                Console.WriteLine("\tPhone:      " + newAccountBeingCreated.CustomerPersonalInformation.PhoneNumber);

                Console.WriteLine("\n\tEmail:      " + newAccountBeingCreated.AccountEmailAddressAndUsername);

                UIHelpers.ResetColor();
                Console.WriteLine("\n\t(Y) - Yes, let's continue");
                Console.WriteLine("\t(N) - No, let's start over\n");


                Console.Write("\n\tSelection: ");

                ConsoleKey verifyCustomerInformationResponse = Console.ReadKey().Key;
                Console.Write("\x1B[1D" + "\x1B[1P" + verifyCustomerInformationResponse.ToString().ToUpper());

                if (verifyCustomerInformationResponse == ConsoleKey.Y)
                {
                    currentUser = CreatePassword(newAccountBeingCreated);
                }
                else if (verifyCustomerInformationResponse == ConsoleKey.N)
                {
                    UIHelpers.Clear();
                    currentUser = null;
                    return(Register(RegistrationEnum.RegisterEmail));
                }
                else
                {
                    return(Register(RegistrationEnum.RegistrationFinalVerification));
                }

                break;
            }//End Switch

            return(AccountMenuView.AccountMainMenu(currentUser));
        }
Ejemplo n.º 4
0
        //Seems like helper functions could simplify this
        public static Account MakingATransaction(Account userMakingTransaction, string typeOfTransaction = "Deposit", bool isInitialDeposit = false)
        {
            decimal initialDeposit;
            decimal depositAmount;
            decimal withdrawalAmount;
            string amountStr;
            bool success;

            decimal currentAccountBalance = userMakingTransaction.CustomerFinancialInformation.AccountBalance;

            if (typeOfTransaction == "Withdrawal")
            {
                if (currentAccountBalance > 5m)
                {
                    UIHelpers.Clear();
                    Console.Write("\t('X + Return' to Cancel)");
                    Console.WriteLine("\n\tYour current balance is: {0:C}", currentAccountBalance);
                    Console.Write("\n\tHow much would you like to ");
                    UIHelpers.DangerColor();
                    Console.Write("withdraw");
                    UIHelpers.ResetColor();
                    Console.Write("? ");
                    amountStr = Console.ReadLine();

                    if (amountStr.ToUpper() == "X")
                    {
                        CancelTransaction();
                        return AccountMainMenu(userMakingTransaction);
                    }

                    success = decimal.TryParse(amountStr, out withdrawalAmount);
                    withdrawalAmount = Math.Abs(withdrawalAmount) * -1;


                    if (success && (currentAccountBalance + withdrawalAmount >= 5m) && withdrawalAmount != 0m)
                    {
                        TransactionHelper(userMakingTransaction, typeOfTransaction, withdrawalAmount, false);
                    }
                    else
                    {
                        UIHelpers.DangerColor();
                        Console.WriteLine("\n\tOOPS! You don't have enough money to withdraw {0:C}.", withdrawalAmount);
                        Console.WriteLine("\n\tYou must keep an account balance of at least $5.00.");
                        Console.Write("\tPress 'Spacebar' to try again...");
                        UIHelpers.ResetColor();
                        ConsoleKey tryWithdrawalAgain = Console.ReadKey().Key;
                        if (tryWithdrawalAgain == ConsoleKey.Spacebar)
                        {
                            return MakingATransaction(userMakingTransaction, typeOfTransaction, isInitialDeposit);
                        }
                    }
                }
                else
                {
                    UIHelpers.DangerColor();
                    Console.WriteLine("\n\tOOPS! You don't have enough money to make a withdrawal.");
                    Console.WriteLine("\n\tYou must keep an account balance of at least $5.00.");
                    Console.Write("\tPress 'Spacebar' to return to Account Main Menu.");
                    UIHelpers.ResetColor();
                    ConsoleKey returnToMainMenu = Console.ReadKey().Key;
                    if (returnToMainMenu == ConsoleKey.Spacebar)
                    {
                        return AccountMainMenu(userMakingTransaction);
                    }
                }
            }

            //Coming from Registration
            else if (isInitialDeposit)
            {
                Console.Write("\n\t('X + Return' to Cancel)");
                Console.Write("\n\tHow much would you like to deposit? ");
                amountStr = Console.ReadLine();

                if (amountStr.ToUpper() == "X")
                {
                    CancelTransaction();
                    return RegisterController.FinancialAccountSetup(userMakingTransaction);
                }

                success = decimal.TryParse(amountStr, out initialDeposit);

                if (success && initialDeposit >= 5m)
                {
                    TransactionHelper(userMakingTransaction, typeOfTransaction, initialDeposit, true);
                }
                else
                {
                    UIHelpers.DangerColor();
                    Console.WriteLine("\n\tPlease open account with at least $5.00");
                    UIHelpers.ResetColor();
                    return MakingATransaction(userMakingTransaction, typeOfTransaction, isInitialDeposit);
                }
            } // end initial deposit

            //Coming from Account Menu
            else //general deposit
            {
                UIHelpers.Clear();
                Console.Write("\t('X + Return' to Cancel)");
                Console.WriteLine("\n\tYour current balance is: {0:C}", currentAccountBalance);
                Console.Write("\n\tHow much would you like to deposit? ");
                amountStr = Console.ReadLine();

                if (amountStr.ToUpper() == "X")
                {
                    CancelTransaction();
                    return AccountMainMenu(userMakingTransaction);
                }

                success = decimal.TryParse(amountStr, out depositAmount);

                if (success && depositAmount >= 0m)
                {
                    TransactionHelper(userMakingTransaction, typeOfTransaction, depositAmount, false);
                }
                else
                {
                    UIHelpers.DangerColor();
                    Console.WriteLine("\n\tPlease deposit more than $0.00");
                    UIHelpers.ResetColor();
                    return MakingATransaction(userMakingTransaction, typeOfTransaction, isInitialDeposit);
                }
            }// end general deposit

            return userMakingTransaction;

        }//End MakingTransaction Method