public void LoginAsManager() { ManagerService managerService = new ManagerService(ref Repo); Manager managerLoggingIn; Console.WriteLine("Please put in your email, then your password to login."); managerLoggingIn = managerService.GetManagerByEmail(UserRequestUtility.QueryEmail()); string userInputPassword; if (managerLoggingIn is null) { Console.WriteLine("Couldn't find a manager matching that email. You can try again if you want, that'll be fun."); LoginMenu loginMenuButAgain = new LoginMenu(ref Repo); MenuManager.Instance.ReadyNextMenu(loginMenuButAgain); } else if (managerLoggingIn is Manager) { userInputPassword = UserRequestUtility.QueryPassword(); while (userInputPassword != managerLoggingIn.Password) { Console.WriteLine("Wrong password. You can try again, though. Why not?"); userInputPassword = UserRequestUtility.QueryPassword(); } // TODO: Move to Manager menu. ManagerStartMenu managerMenu = new ManagerStartMenu(managerLoggingIn, ref Repo); MenuManager.Instance.ReadyNextMenu(managerMenu); } }
public void LoginAsUser() { StartService startService = new StartService(ref Repo); User userLoggingIn; // TODO: Implement Login functionality for existing users Console.WriteLine("Please put in your email, then your password to login."); userLoggingIn = startService.GetUserByEmail(UserRequestUtility.QueryEmail()); if (userLoggingIn is null) { Console.WriteLine("Couldn't find a user matching that email. You can try again if you want, that'll be fun."); LoginMenu loginMenuButAgain = new LoginMenu(ref Repo); MenuManager.Instance.ReadyNextMenu(loginMenuButAgain); } else if (userLoggingIn is Customer || userLoggingIn is Manager) { string userInputPassword = UserRequestUtility.QueryPassword(); while (userInputPassword != userLoggingIn.Password) { userInputPassword = UserRequestUtility.QueryPassword(); } } // TODO: When SignUp() ends, add the new customer data to DB/file switch (selectedChoice) { case 1: //TODO: Update a database with an added customer using BL. break; case 2: //TODO: Update a database with an added manager using BL. break; default: throw new NotImplementedException(); //break; } //TODO: Check at Login() if the inputted email and password match any existing customer or Manager, then make the current user either customer or manager. // TODO: Move to next menu. }
public override void ExecuteUserChoice() { // Sign Up functionality StartService startService = new StartService(ref Repo); // 1: Ask for email string newEmail = UserRequestUtility.QueryEmail(); // 2: check if email matches with any other customer if (startService.DoesUserExistWithEmail(newEmail)) { Console.WriteLine("That email already exists for a user of the program. You really should be logging in instead. \n Taking you back to the start.."); MenuManager.Instance.ReadyNextMenu(new StartMenu(ref Repo)); return; } // 3: ask for password, then name and address string newPassword = UserRequestUtility.QueryPasswordAndConfirmation(); string newName = UserRequestUtility.QueryName(); // When SignUp() ends, add the new customer data to DB/file switch (selectedChoice) { case 1: // Update a database with an added customer using BL. string newAddress = UserRequestUtility.QueryAddress(); Customer newCustomer = new Customer(newName, newEmail, newPassword, newAddress); CustomerService customerService = new CustomerService(ref Repo); customerService.AddCustomerToRepo(newCustomer); break; case 2: Manager newManager = new Manager(newName, newEmail, newPassword); ManagerSignUpSubMenu managerSignUpMenu = new ManagerSignUpSubMenu(ref Repo, ref newManager); Manager updatedManager = managerSignUpMenu.RunAndReturnManagerWithSelectedLocation(); ManagerService managerService = new ManagerService(ref Repo); managerService.AddManager(updatedManager); break; default: throw new NotImplementedException(); //break; } Console.WriteLine("You've now signed up! Now type all that garbage again to login!"); MenuManager.Instance.ReadyNextMenu(loginMenu); }
public static void ProcessSortingByPrice(ref bool sortOrder) { string sortStartMessage = "You've chosen to sort orders by subtotal. Sort from lowest to highest subtotal, or highest to lowest subtotal?"; List <string> sortOptions = new List <string>(2) { "Lowest to highest.", "Highest to Lowest." }; UserResponseUtility.DisplayPossibleChoicesToUser(sortStartMessage, sortOptions); sortOrder = (UserRequestUtility.ProcessUserInputAgainstPossibleChoices(sortOptions)) switch { 1 => true, 2 => false, _ => throw new NotImplementedException(), }; }
public static void ProcessSortingByDate(ref bool sortOrder) { string sortStartMessage = "Would you like the results sorted oldest to latest or latest to oldest?"; List <string> sortOptions = new List <string>(2) { "Oldest to Latest.", "Latest to Oldest." }; UserResponseUtility.DisplayPossibleChoicesToUser(sortStartMessage, sortOptions); sortOrder = (UserRequestUtility.ProcessUserInputAgainstPossibleChoices(sortOptions)) switch { 1 => true, 2 => false, _ => throw new NotImplementedException(), }; }
/// <summary> /// This method handles each interaction the user has with the menu. /// </summary> public void QueryUserChoice() { selectedChoice = UserRequestUtility.ProcessUserInputAgainstPossibleChoices(PossibleOptions); Console.WriteLine(); }