示例#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
        //Method for displaying transaction history
        public static Account TransactionHistoryLog(Account userMakingTransaction)
        {
            //Layout for transaction log
            UIHelpers.Clear();
            Console.WriteLine("\t======================================================================");
            Console.WriteLine("\tTransaction Log");
            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("\tAvailable Balance:\t{0:C}", userMakingTransaction.CustomerFinancialInformation.AccountBalance);
            Console.WriteLine("\t======================================================================");
            Console.WriteLine("\n");
            Console.WriteLine("\tList of Account Transactions:");

            //Actual call to get transaction data
            userMakingTransaction.CustomerFinancialInformation.AccountTransactions.ForEach(Console.WriteLine);

            //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;
        }
示例#4
0
        //Method for displaying account balance
        public static Account TransactionReceipt(Account userMakingTransaction)
        {
            var transaction = userMakingTransaction.CustomerFinancialInformation.AccountTransactions[0];
            //Layout for balance display
            UIHelpers.Clear();
            Console.WriteLine("\t==================================================");
            Console.WriteLine("\tTransaction Receipt");
            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("\tAvailable Balance:\t{0:C}", userMakingTransaction.CustomerFinancialInformation.AccountBalance);
            Console.WriteLine("\t==================================================");
            Console.WriteLine("\n");
            Console.WriteLine("\tDetails of your recent transaction:\n");
            Console.WriteLine("\tTransaction Date:   \t{0}", transaction.TransactionDate);
            Console.WriteLine("\tTransaction ID:     \t{0}\n", transaction.TransactionID);
            Console.WriteLine("\tTransaction Type:   \t{0}", transaction.TransactionType);
            Console.WriteLine("\tTransaction Amount: \t{0:C}", transaction.TransactionAmount);

            //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;
        }
示例#5
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);
        }
示例#6
0
 //Helper Method for already registered user failing login
 public static void FailedLogin()
 {
     UIHelpers.DangerColor();
     Console.Write("\n\tWe are sorry. You have failed logging in 3 times.\n\tPlease try again later or contact customer support.\n\n\tPress any key to exit.");
     UIHelpers.ResetColor();
     Console.ReadKey();
     UIHelpers.Clear();
 }
示例#7
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;
        }
示例#8
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();
        }
示例#9
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;
        }
示例#10
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));
        }
示例#11
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