示例#1
0
        //Method for verify inputs on registering
        //Returns bool to RegisterMethod for error handling
        public static bool VerifyInput(string fieldData, string fieldLabel)
        {
            Console.Write("\n\tPlease verify your " + fieldLabel + " (");
            UIHelpers.WarningColor();
            Console.Write(fieldData);
            UIHelpers.ResetColor();
            Console.Write(") is correct? (Y\\N) ");
            ConsoleKey responseToVerification = Console.ReadKey().Key;

            Console.Write("\x1B[1D" + "\x1B[1P" + responseToVerification.ToString().ToUpper());
            //

            if (responseToVerification == ConsoleKey.Y)
            {
                UIHelpers.Clear();
                UIHelpers.WarningColor();
                Console.WriteLine("\tAccount Setup");
                UIHelpers.ResetColor();
            }
            else
            {
                return(false);
            }
            return(true);
        }
示例#2
0
        //Method for initial deposit to open account
        //Returns user to CreatePasswordMethod
        public static Account FinancialAccountSetup(Account userFromCreatePasswordMethod)
        {
            UIHelpers.Clear();
            UIHelpers.WarningColor();
            Console.WriteLine("\n\tAlmost finished...");
            UIHelpers.ResetColor();
            Console.WriteLine("\n\tIn order to finish openning an account, you must make an initial deposit of at least $5.00.");
            Console.Write("\n\tWhat type of account do you want to open? (S) - Savings or (C) - Checking? ");
            ConsoleKey responseToAccountType = Console.ReadKey().Key;

            Console.Write("\x1B[1D" + "\x1B[1P" + responseToAccountType.ToString().ToUpper());

            if (responseToAccountType == ConsoleKey.S)
            {
                //
                userFromCreatePasswordMethod.CustomerFinancialInformation.AccountType   = "Savings";
                userFromCreatePasswordMethod.CustomerFinancialInformation.AccountNumber = FinancialModel.NextAccountNumber;
                FinancialModel.UpdateNextAccountNumber();
                AccountMenuView.MakingATransaction(userFromCreatePasswordMethod, "Deposit", true);
            }
            else if (responseToAccountType == ConsoleKey.C)
            {
                //
                userFromCreatePasswordMethod.CustomerFinancialInformation.AccountType   = "Checking";
                userFromCreatePasswordMethod.CustomerFinancialInformation.AccountNumber = FinancialModel.NextAccountNumber;
                FinancialModel.UpdateNextAccountNumber();
                AccountMenuView.MakingATransaction(userFromCreatePasswordMethod, "Deposit", true);
            }
            else
            {
                return(FinancialAccountSetup(userFromCreatePasswordMethod));
            }

            return(userFromCreatePasswordMethod);
        }
示例#3
0
        }//End MakingTransaction Method


        //Method helper to allow a user to cancel out of a transaction
        public static void CancelTransaction()
        {
            UIHelpers.WarningColor();
            Console.WriteLine("\n\tCanceling the transaction.");
            System.Threading.Thread.Sleep(2500);
            //AccountMainMenu(userMakingTransaction);
        }
示例#4
0
        public static Account LoginOrRegister(Account currentUser)
        {
            UIHelpers.Clear();
            Console.WriteLine("\tWhat would you like to do?\n\n\t\t(L) - Login\n\t\t(R) - Register ");
            Console.Write("\n\tSelection: ");
            ConsoleKey loginOrRegisterResponse = Console.ReadKey().Key;

            Console.Write("\x1B[1D" + "\x1B[1P" + loginOrRegisterResponse.ToString().ToUpper());

            if (loginOrRegisterResponse == ConsoleKey.L)
            {
                UIHelpers.Clear();
                currentUser = LoginController.LoginEmail(loginAttempts);
            }
            else if (loginOrRegisterResponse == ConsoleKey.R)
            {
                UIHelpers.Clear();
                UIHelpers.WarningColor();
                Console.WriteLine("\tLet's get an account setup for you!");
                UIHelpers.ResetColor();
                currentUser = RegisterController.Register(RegistrationEnum.RegisterEmail);
            }
            else
            {
                UIHelpers.DangerColor();
                Console.WriteLine("\n\tThat is an invalid entry. Please select 'L' to Login or 'R' to Register.\n");
                System.Threading.Thread.Sleep(1000);
                UIHelpers.ResetColor();
                currentUser = null;
                LoginOrRegister(currentUser);
            }

            return(currentUser);
        }
示例#5
0
        //Main method for account
        //Allows all user actions
        //Returns currentUser to LoginOrRegister
        public static Account AccountMainMenu(Account currentLoggedInUser)
        {
            var currentUser = currentLoggedInUser;

            UIHelpers.Clear();
            Console.Write("\n\tWelcome ");
            UIHelpers.WarningColor();
            Console.Write("{0} {1}", currentUser.CustomerPersonalInformation.FirstName, currentUser.CustomerPersonalInformation.LastName);
            UIHelpers.ResetColor();
            Console.Write(" To The Main Menu.\n\tWhat would you like to do?\n");
            Console.WriteLine("\n\t(D) - Make a Deposit");
            Console.WriteLine("\n\t(W) - Make a Withdrawal");
            Console.WriteLine("\n\t(B) - Check your Available Balance");
            Console.WriteLine("\n\t(T) - View Recent Transaction History");
            Console.WriteLine("\n\t(X) - Logout\n");
            Console.Write("\n\n\tSelection: ");

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

            if (accountMenuActionResponse == ConsoleKey.X)
            {
                //Reset Current User to Null and Send Back To LoginView
                currentUser = null;
                UIHelpers.Clear();
                Program.LoginOrRegister(currentUser);
            }
            else if (accountMenuActionResponse == ConsoleKey.D)
            {
                MakingATransaction(currentUser, "Deposit", false);
            }
            else if (accountMenuActionResponse == ConsoleKey.W)
            {
                MakingATransaction(currentUser, "Withdrawal", false);
            }
            else if (accountMenuActionResponse == ConsoleKey.B)
            {
                CheckAccountBalance(currentUser);
            }
            else if (accountMenuActionResponse == ConsoleKey.T)
            {
                TransactionHistoryLog(currentUser);
            }
            else
            {
                return AccountMainMenu(currentUser);
            }

            return currentUser;
        }
示例#6
0
        //Method helper for common aspects of making a transaction
        public static Account TransactionHelper(Account userMakingTransaction, string typeOfTransaction, decimal transAmount, bool isInitialDeposit)
        {
            Console.Write("\n\tYou are ");

            if(typeOfTransaction == "Deposit")
            {
                Console.Write("depositing");
            }
            else
            {
                UIHelpers.DangerColor();
                Console.Write("withdrawing");
                UIHelpers.ResetColor();
            }
            Console.Write(" {0:C} is that correct? (Y\\N\\x) ", transAmount);
            ConsoleKey verifyTranactionAmount = Console.ReadKey().Key;
            Console.Write("\x1B[1D" + "\x1B[1P" + verifyTranactionAmount.ToString().ToUpper());

            if (verifyTranactionAmount == ConsoleKey.Y)
            {
                Console.Write("\n");
                var transaction = new TransactionModel(typeOfTransaction, transAmount);
                userMakingTransaction.CustomerFinancialInformation.AccountBalance += (decimal)transAmount;

                //Insert over add to list
                //This way, [0] is always the last item
                userMakingTransaction.CustomerFinancialInformation.AccountTransactions.Insert(0, transaction);
                TransactionReceipt(userMakingTransaction);
            }
            else if (verifyTranactionAmount == ConsoleKey.X)
            {
                if(isInitialDeposit)
                {
                    return RegisterController.FinancialAccountSetup(userMakingTransaction);
                }

                UIHelpers.WarningColor();
                Console.WriteLine("\n\tCanceling the transacation and returning to Account Main Menu.");
                System.Threading.Thread.Sleep(2500);
                return AccountMainMenu(userMakingTransaction);
            }
            else
            {
                return MakingATransaction(userMakingTransaction, typeOfTransaction, isInitialDeposit);
            }

            return userMakingTransaction;
        }
示例#7
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));
        }