//Options User Interface //Allows user to Place an order at set location //Allows user to view its full order history //Allows user to select another location //Allows user to sign out public static void optionsUI() { while (true) { Console.Clear(); string select; Console.WriteLine("1. Place an Order"); Console.WriteLine("2. View Order History"); Console.WriteLine("3. Select Another Location"); Console.WriteLine("4. Sign Out"); Console.Write("Please select an option: "); select = (Console.ReadLine()); switch (select) { case "1": if (DateTimeCheck.checkDT()) // will check if user has odered from this location in the last 24 hours // or last 2 hours in any location { orderUI(); } else { Console.WriteLine(); Console.WriteLine("Press any key to return to other options"); Console.ReadKey(); } break; case "2": historyUI(); // send to order history user interface break; case "3": locationUI(); // send to reselect a location user interface break; case "4": MainUI.startupUI(); // send to Main Menu break; default: Console.WriteLine("Invalid Choice"); Console.WriteLine("Press any key to try again"); Console.ReadKey(); break; } } }
//Employee Login User Interface //prompts employee user to login //checks if username and password entered is present in the database public static void empLoginUI() { while (true) { Console.Clear(); string Id; string passWord; Console.WriteLine("Store Login"); Console.Write("Username: "******"Password: "******"Invalid Username or Password"); Console.WriteLine("Press 'b' to return to last page or any other key to try again"); ConsoleKeyInfo key; key = Console.ReadKey(); Console.WriteLine(); switch (key.Key) { case ConsoleKey.B: MainUI.startupUI(); break; default: empLoginUI(); break; } } }
//Login User Interface //prompts user to login //checks if username and password entered is present in the database public static void loginUI() { while (true) { Console.Clear(); string userName; string passWord; Console.WriteLine("Welcome to Marquez's Pizzaria"); Console.Write("Username: "******"Password: "******"Invalid Username or Password"); Console.WriteLine("Press 'b' to return to last page or any other key to try again"); ConsoleKeyInfo key; key = Console.ReadKey(); Console.WriteLine(); switch (key.Key) { case ConsoleKey.B: MainUI.startupUI(); break; default: loginUI(); break; } } }
//Location User Interface //promps the user to choose a location for order //location information is stored for future references public static void locationUI() { while (true) { Console.Clear(); string location; int locat; int counter = 0; Console.WriteLine("Hello {0}", PCustomer.firstname); Console.WriteLine(); Entity db = AccessDb.acc(); //Singleton used to access data var locations = Repository.GetLocations(db); //gets all locations from the location table foreach (var loc in locations) { Console.WriteLine($"{loc.Id}. {loc.Locat}"); counter++; // counter used to see how many locations are in the system, can add more locations if needed } Console.WriteLine(); Console.Write("Please Select a Location: "); location = Console.ReadLine(); int value; if (int.TryParse(location, out value)) // location id and address is stored for record purposes { locat = Convert.ToInt32(location); if (locat <= counter && locat > 0) { foreach (var loc in locations) { if (loc.Id == locat) { Location.Id = loc.Id; // stores location information Location.Locat = loc.Locat; } } optionsUI(); break; } else { Console.WriteLine("Invalid Input"); Console.WriteLine("Press 'b' to return to Main Menu or any other key to try again"); ConsoleKeyInfo key; key = Console.ReadKey(); Console.WriteLine(); switch (key.Key) { case ConsoleKey.B: MainUI.startupUI(); //return to Main Menu break; default: break; } } } else { Console.WriteLine("Invalid Input"); Console.WriteLine("Press 'b' to return to Main Menu or any other key to try again"); ConsoleKeyInfo key; key = Console.ReadKey(); Console.WriteLine(); switch (key.Key) { case ConsoleKey.B: MainUI.startupUI(); break; default: break; } } } }
//Store Location User Interface //Allows employee to view order histoy of every location //Allows employee to view total order history of all locations public static void storelocationUI() { while (true) { Console.Clear(); string location; int locat; int counter = 0; Console.WriteLine("Hello Employee {0}", Pemployee.firstname); Console.WriteLine(); Entity db = AccessDb.acc(); //Singleton used to access data var locations = Repository.GetLocations(db); foreach (var loc in locations) { Console.WriteLine($"{loc.Id}. {loc.Locat}"); counter++; // counter used to see how many locations are in the system } Console.WriteLine(); Console.WriteLine("a. All Locations"); Console.WriteLine("s. Sign Out"); Console.WriteLine(); Console.Write("Please Select a Location to view order history: "); location = Console.ReadLine(); Console.WriteLine(); int value; if (int.TryParse(location, out value)) // location id and address is stored for record purposes { locat = Convert.ToInt32(location); if (locat <= counter && locat > 0) { foreach (var loc in locations) { if (loc.Id == locat) // stores location for future reference { Location.Id = loc.Id; Location.Locat = loc.Locat; } } singlestoreUI(); // displays location store order history break; } else { Console.WriteLine("Invalid Input"); Console.WriteLine("Press 'b' to return to Main Menu or any other key to try again"); ConsoleKeyInfo key; key = Console.ReadKey(); Console.WriteLine(); switch (key.Key) { case ConsoleKey.B: MainUI.startupUI(); break; default: break; } } } else if (location == "a") // displays total order history { totstoreUI(); } else if (location == "s") { MainUI.startupUI(); } else { Console.WriteLine("Invalid Input"); Console.WriteLine("Press 'b' to return to Main Menu or any other key to try again"); ConsoleKeyInfo key; key = Console.ReadKey(); Console.WriteLine(); switch (key.Key) { case ConsoleKey.B: MainUI.startupUI(); break; default: break; } } } }
// Register User Interface // Promts user to enter firstname, lastname, username, and password // Prevents user from creating an account with repeated username public static void registerUI() { while (true) { Console.Clear(); string newId; string newPassword; string nameFirst; string nameLast; Console.WriteLine("Create an Account"); Console.WriteLine(); Console.Write("First Name: "); nameFirst = Console.ReadLine(); Console.Write("Last Name: "); nameLast = Console.ReadLine(); Console.Write("Username: "******"Password: "******"No null values allowed when creating an account"); Console.WriteLine("Press 'b' to return to last page or any other key to try again"); ConsoleKeyInfo key1; key1 = Console.ReadKey(); Console.WriteLine(); switch (key1.Key) { case ConsoleKey.B: MainUI.startupUI(); break; default: registerUI(); break; } } Entity db = AccessDb.acc(); //Singleton used to access data var customers = Repository.GetCustomer(db); foreach (var cus in customers) { if (cus.Uname == newId) // checks if entered username is already stored in database { Console.WriteLine($"Invalid username. There is already an account with the username '{newId}'"); Console.WriteLine("Press 'b' to return to last page or any other key to try again"); ConsoleKeyInfo key; key = Console.ReadKey(); Console.WriteLine(); switch (key.Key) { case ConsoleKey.B: MainUI.startupUI(); break; default: registerUI(); Thread.Sleep(2000); break; } } } Console.Write("Are you sure you want to create an account with this information? y/n: "); string confirm; confirm = Console.ReadLine(); if (confirm == "y") { Customer customer = new Customer() { Fname = nameFirst, Lname = nameLast, Uname = newId, Pword = newPassword }; Repository.AddCustomer(db, customer); // adds customer to customer table Console.WriteLine("Success! Your account has been created"); Thread.Sleep(2000); MainUI.startupUI(); } else if (confirm == "n") { Console.WriteLine("Press 'b' to return to last page or any other key to try again"); ConsoleKeyInfo key1; key1 = Console.ReadKey(); Console.WriteLine(); switch (key1.Key) { case ConsoleKey.B: MainUI.startupUI(); break; default: registerUI(); break; } } else { Console.WriteLine("Incorrect Input"); Console.WriteLine("Press 'b' to return to last page or any other key to try again"); ConsoleKeyInfo key1; key1 = Console.ReadKey(); Console.WriteLine(); switch (key1.Key) { case ConsoleKey.B: MainUI.startupUI(); break; default: registerUI(); break; } } } }