/// <summary> /// Choose menu "Change product data" /// </summary> public static void ChangeProductDataByAdmin() { string inputName, inputPrice, inputProductId; int productId; decimal price; Print.PrintHeader("Change product data", ConsoleColor.DarkYellow); inputProductId = Print.ReadInput("Enter product ID:"); productId = ParseInput.IsCorrectId(inputProductId); if (productId == -1) { return; } if (!StartActions.AdminLogic.ProductExist(productId)) { Console.WriteLine("Such product doesn't exist!"); return; } string input = Print.ReadInput("Enter what you need to change\n[1] Product name\n[2] Product price"); if (input == "1") { inputName = Print.ReadInput("Enter new name:"); if (!ParseInput.IsCorrectName(inputName)) { return; } if (StartActions.AdminLogic.ChangeProductName(productId, inputName)) { Console.WriteLine("Name changed!"); } else { Console.WriteLine("Incorrect input!"); } } else if (input == "2") { inputPrice = Print.ReadInput("Enter new price:"); price = ParseInput.IsCorrectPrice(inputPrice); if (price == -1) { return; } if (StartActions.AdminLogic.ChangeProductPrice(productId, price)) { Console.WriteLine("Price changed!"); } else { Console.WriteLine("Incorrect input!"); } } else { Console.WriteLine("Incorrect input!"); } }
/// <summary> /// Choose menu 'Register' /// </summary> public static void Register() { GuestLogic = new GuestLogic(); string name, email, password, input; while (true) { Console.Clear(); Print.PrintHeader("REGISTER", ConsoleColor.DarkYellow); name = Print.ReadInput("\nEnter your name (at least 3 characters): "); if (!ParseInput.IsCorrectName(name)) { Console.WriteLine("\nIncorrect name!"); input = Print.ReadInput("\n[1] Try again\nor enter any other key to return"); if (input != "1") { return; } else { continue; } } email = Print.ReadInput("\nEnter user email (*****@***): "); if (!ParseInput.IsCorrectEmail(email)) { Console.WriteLine("\nIncorrect email!"); input = Print.ReadInput("\n[1] Try again\nor enter any other key to return"); if (input != "1") { return; } else { continue; } } password = Print.ReadInput("\nEnter password (at least 3 characters): "); if (!ParseInput.IsCorrectPassword(password)) { Console.WriteLine("\nIncorrect password!"); input = Print.ReadInput("\n[1] Try again\nor enter any other key to return"); if (input != "1") { return; } else { continue; } } if (!GuestLogic.Register(name, email, password)) { Console.WriteLine("\nUser with this email already exists!"); input = Print.ReadInput("\n[1] Try again\nor enter any other key to return"); if (input != "1") { return; } } else { break; } } GuestLogic.LogIn(email, password); Console.Clear(); if (UserLogic.GetAccountType().Equals("USER")) { UserActions.UserMode(); } else { UserActions.AdminMode(); } while (true) { Print.PrintHeader($"{UserLogic.GetAccountType()}: {UserLogic.GetAccountName()}", ConsoleColor.Green); UserActions.GetActions(); input = Console.ReadLine(); Console.Clear(); Print.PrintHeader($"{UserLogic.GetAccountType()}: {UserLogic.GetAccountName()}", ConsoleColor.Green); if (input.ToLower() == "q") { UserLogic.LogOut(); break; } UserActions.ChooseAction(input); } }