public void EditAccountDetails() { Console.Clear(); Console.WriteLine("You have been redirected to ACCOUNT_DETAILS"); Console.WriteLine(); Console.WriteLine($"User = {CurrentUser.GetName()}, Location = {CurrentUser.GetLocation()}"); Console.WriteLine(); Console.WriteLine("What would you like to do?"); List <string> Options = new List <string> { "Change Username", "Change Location", "Change Password" }; for (int i = 0; i < Options.Count; i++) { Console.WriteLine($"{i+1}. {Options[i]}"); } Console.WriteLine($"Enter 'B' or '0' to go back to Main Menu."); var MyInputCollector = new InputCollector(); int input = 0; bool GoodNumber = false; while (!GoodNumber) { input = MyInputCollector.GetNumber(); if (!(input < 0 || input > Options.Count)) { GoodNumber = true; } if (GoodNumber == false) { Console.WriteLine("That number is not on the list!"); } } if (input == 0) { return; } else if (input == 1) { var NewUserName = new MakeNewUser(this, MyStoreManager); string x = NewUserName.GetDesiredUsername(); CurrentUser.SetName(x); Console.WriteLine($"Username changed to {x}"); Console.WriteLine("Press enter to continue."); Console.ReadLine(); EditAccountDetails(); } else if (input == 2) { var NewUserName = new MakeNewUser(this, MyStoreManager); string x = NewUserName.GetDesiredLocation(); CurrentUser.SetLocation(x); Console.WriteLine($"Location changed to {x}"); Console.WriteLine("Press enter to continue."); Console.ReadLine(); EditAccountDetails(); } else if (input == 3) { var NewUserName = new MakeNewUser(this, MyStoreManager); string x = NewUserName.GetDesiredPassword(); CurrentUser.SetPassword(x); x = NewUserName.GetStarredPassword(x); Console.WriteLine($"Password changed. {x}"); Console.WriteLine("Press enter to continue."); Console.ReadLine(); EditAccountDetails(); } return; }
/// <summary> /// This method represents the admin editing a selected user. Prints all the info about the user and asks the admin what about the user they would like to change. /// If the admin picks the username,location, or password this method calls a cooresponding method inside of our user build to make a new username,location, or password. /// If the admin picks the employee tag, it is changed using a setter through the person manager. End of internal logic line. Returns to admin menu. /// Note: admin employee status can not be removed. /// </summary> private void InProcessEditingUser(Person MyCurrentPerson) { Console.Clear(); Console.WriteLine($"Currently Selected User: {MyCurrentPerson.GetName()}"); Console.WriteLine($"Current Location: {MyCurrentPerson.GetLocation()}"); Console.WriteLine($"Current Password: {MyCurrentPerson.GetPassword()}"); Console.WriteLine($"Employee: {MyCurrentPerson.GetEmployeeTag()}"); Console.WriteLine("What would you like to change?"); List <string> EmployeeUserChangeOptions = new List <string> { "Change Username", "Change Location", "Change Password", "Change Employee Status" }; Console.WriteLine(""); for (int i = 0; i < EmployeeUserChangeOptions.Count; i++) { Console.WriteLine($"{i+1}. {EmployeeUserChangeOptions[i]}"); } Console.WriteLine($"Enter 'B' or '0' to go back to Admin Menu."); Console.WriteLine(); bool GoodChoice = false; int input = 0; while (!GoodChoice) { input = MyInputCollector.GetNumber(); if (!(input < 0 || input > EmployeeUserChangeOptions.Count)) { GoodChoice = true; } if (GoodChoice == false) { Console.WriteLine("That number is not on the list!"); } } if (input == 0) { return; } else if (input == 1) { MyCurrentPerson.SetName(MyNewUserInput.GetDesiredUsername()); Console.WriteLine("Username set."); Console.WriteLine("Press enter to continue."); Console.ReadLine(); } else if (input == 2) { MyCurrentPerson.SetLocation(MyNewUserInput.GetDesiredLocation()); Console.WriteLine("Location set."); Console.WriteLine("Press enter to continue."); Console.ReadLine(); } else if (input == 3) { MyCurrentPerson.SetPassword(MyNewUserInput.GetDesiredPassword()); Console.WriteLine("Password set."); Console.WriteLine("Press enter to continue."); Console.ReadLine(); } else if (input == 4) { bool IsEmployee = MyCurrentPerson.GetEmployeeTag(); if (IsEmployee && MyCurrentPerson.GetName() != "admin") { MyCurrentPerson.SetEmployeeTag(false); Console.WriteLine($"{MyCurrentPerson.GetName()} is no longer an employee."); } else if (!IsEmployee && MyCurrentPerson.GetName() != "admin") { MyCurrentPerson.SetEmployeeTag(true); Console.WriteLine($"{MyCurrentPerson.GetName()} is now an employee."); } else { Console.WriteLine("Admin can never be removed from staff."); } Console.WriteLine("Press enter to continue."); Console.ReadLine(); } return; }