static void OrderConfirmMenu() { var pizzasRepo = Dependencies.CreatePizzaRepository(); var ordersRepo = Dependencies.CreateOrderRepository(); Orders currOrder = ordersRepo.GetCurrentOrder(); OptionsGenerator extraOptions = new OptionsGenerator(); extraOptions.Add("c", "Confirm Order"); extraOptions.Add("x", "Cancel Order"); extraOptions.Add("e", "Edit Order(TODO)"); extraOptions.Add("b", "Back to Store Menu"); extraOptions.Add("q", "Quit"); List <Pizza> pizzas = ordersRepo.GetCurrOrderPizzas(); if (pizzas.Count <= 0) { Console.WriteLine("NO CURRENT ORDER"); PressAnyToContinue(); RestaurantMenu(); } string userInput; do { var customersRepo = Dependencies.CreateCustomerRepository(); Customers currCustomer = customersRepo.GetCurrentCustomer(); var restaurantsRepo = Dependencies.CreateRestaurantRepository(); Restaurants currRestaurant = restaurantsRepo.GetCurrentRestaurant(); Console.Clear(); Console.WriteLine("\n" + PadMiddle($"View Order ({currCustomer.Username}) ({currRestaurant.RestaurantName}) (Total = $)")); int i = 1; foreach (Pizza p in pizzas) { DashPaddings(); Console.WriteLine("Pizza #".PadRight(10) + i); pizzasRepo.DisplayFullPizzaInfo(p, currRestaurant.RestaurantMarkup.Value); Console.WriteLine("\n" + $"Total# {i}:".PadRight(70) + $"$ {pizzasRepo.GetTotalPrice(p).ToString("0.00")}"); i++; } DashPaddings(); Console.WriteLine("Subtotal:".PadRight(70) + $"$ {ordersRepo.GetSubtotal().ToString(("0.00"))}"); DashPaddings(); extraOptions.DisplayOptions(); DashPaddings(); Console.Write("Input: "); userInput = Console.ReadLine(); switch (userInput) { case "c": ordersRepo.SubmitOrder(currCustomer.CustomerId, currRestaurant.RestaurantId); RestaurantSelectMenu(); break; case "x": // cancel order ordersRepo.RemoveCurrOrder(); RestaurantMenu(); break; case "e": //TODO edit order //PizzaSelectMenu(); break; case "b": RestaurantMenu(); break; case "q": Quit(); break; } } while (userInput != "q"); }
static void RestaurantMenu() { var customersRepo = Dependencies.CreateCustomerRepository(); Customers currCustomer = customersRepo.GetCurrentCustomer(); var restaurantsRepo = Dependencies.CreateRestaurantRepository(); Restaurants currRestaurant = restaurantsRepo.GetCurrentRestaurant(); var ordersRepo = Dependencies.CreateOrderRepository(); OptionsGenerator storeMenu = new OptionsGenerator(); storeMenu.Add("p", "PresetPizzas"); storeMenu.Add("c", "CustomPizza(TODO)"); storeMenu.Add("v", "ViewCurrentOrder"); storeMenu.Add("h", "UserStoreOrderHistory"); storeMenu.Add("r", "StoreOrderHistory"); storeMenu.Add("b", "Back to Store Selection"); storeMenu.Add("s", "SignOut"); storeMenu.Add("q", "Quit"); string userInput; do { Console.Clear(); Console.WriteLine("\n" + PadMiddle($"Store Menu ({currRestaurant.RestaurantName}) ({currCustomer.Username}) ")); storeMenu.DisplayOptions(); DashPaddings(); Console.Write("Input: "); userInput = Console.ReadLine(); switch (userInput) { case "p": PresetPizzaMenu(); break; case "c": CustomPizzaMenu(); break; case "v": OrderConfirmMenu(); break; case "h": ordersRepo.ViewOrderHistory(currCustomer.CustomerId, currRestaurant.RestaurantId); PressAnyToContinue(); break; case "r": ordersRepo.ViewStoreOrderHistory(currRestaurant.RestaurantId); PressAnyToContinue(); break; case "b": RestaurantSelectMenu(); break; case "s": SignOut(); break; case "q": Environment.Exit(-1); break; } }while (userInput != "q"); }
static void PresetPizzaMenu() { var customersRepo = Dependencies.CreateCustomerRepository(); Customers currCustomer = customersRepo.GetCurrentCustomer(); var restaurantsRepo = Dependencies.CreateRestaurantRepository(); Restaurants currRestaurant = restaurantsRepo.GetCurrentRestaurant(); var pizzasRepo = Dependencies.CreatePizzaRepository(); List <int> pizzaIDList = restaurantsRepo.GetCurrRestaurantPizzaIDList(); OptionsGenerator extraMenu = new OptionsGenerator(); extraMenu.Add("b", "Back to RestaurantMenu"); extraMenu.Add("q", "Quit"); //OptionsGenerator pizzasMenu = new OptionsGenerator(); //foreach (Pizza p in restaurantsRepo.GetCurrRestaurantPizzas()) //{ // pizzasMenu.Add(p.PizzaId.ToString(), p.PizzaName, pizzasRepo.GetTotalPrice(p.PizzaId) + currRestaurant.RestaurantMarkup.Value); //} string userInput; do { Console.Clear(); Console.WriteLine("\n" + PadMiddle($"Pizza Selection ({currRestaurant.RestaurantName}) ({currCustomer.Username}) ")); Console.WriteLine("Code".PadRight(10) + "Pizza".PadRight(30) + "Personal".PadRight(10) + "Medium".PadRight(10) + "Large".PadRight(10) + "XLarge"); DashPaddings(); foreach (Pizza p in restaurantsRepo.GetCurrRestaurantPizzas()) { string pricePersonal = (pizzasRepo.GetTotalPrice(p.PizzaId, new Size { PriceMultiplier = 0.8 }) + currRestaurant.RestaurantMarkup.Value).ToString("0.00"); string priceMedium = (pizzasRepo.GetTotalPrice(p.PizzaId, new Size { PriceMultiplier = 1 }) + currRestaurant.RestaurantMarkup.Value).ToString("0.00"); string priceLarge = (pizzasRepo.GetTotalPrice(p.PizzaId, new Size { PriceMultiplier = 1.5 }) + currRestaurant.RestaurantMarkup.Value).ToString("0.00"); string priceXtraLarge = (pizzasRepo.GetTotalPrice(p.PizzaId, new Size { PriceMultiplier = 2.1 }) + currRestaurant.RestaurantMarkup.Value).ToString("0.00"); Console.WriteLine(p.PizzaId.ToString().PadRight(10) + p.PizzaName.PadRight(30) + pricePersonal.PadRight(10) + priceMedium.PadRight(10) + priceLarge.PadRight(10) + priceXtraLarge); } //pizzasMenu.DisplayOptions(1); DashPaddings(); extraMenu.DisplayOptions(); DashPaddings(); Console.Write("Input: "); userInput = Console.ReadLine(); if (int.TryParse(userInput, out int pizzaID)) { // numeric input if (pizzaIDList.Contains(pizzaID)) { pizzasRepo.SetCurrentPizza(pizzaID, currRestaurant); Pizza currPizza = pizzasRepo.GetCurrentPizza(); // select pizza Console.Write("\nSize? (p) (m) (l) (x): "); userInput = Console.ReadLine(); if (userInput == "p") { pizzasRepo.SetCurrentPizzaSize(1); } else if (userInput == "m") { pizzasRepo.SetCurrentPizzaSize(2); } else if (userInput == "l") { pizzasRepo.SetCurrentPizzaSize(3); } else if (userInput == "x") { pizzasRepo.SetCurrentPizzaSize(4); } AddPizzaConfirmMenu(); break; } } else if (userInput == "b") { RestaurantMenu(); break; } else if (userInput == "q") { Environment.Exit(-1); break; } } while (userInput != "q"); }
static void RestaurantSelectMenu() { var customersRepo = Dependencies.CreateCustomerRepository(); Customers currCustomer = customersRepo.GetCurrentCustomer(); var restaurantsRepo = Dependencies.CreateRestaurantRepository(); restaurantsRepo.RemoveCurrentRestaurant(); var ordersRepo = Dependencies.CreateOrderRepository(); ordersRepo.RemoveCurrOrder(); List <Restaurants> restaurants = restaurantsRepo.GetRestaurants().ToList(); //OptionsGenerator storeSelectMenu = new OptionsGenerator(); //foreach (Restaurants store in restaurants) //{ // storeSelectMenu.Add(store.RestaurantId.ToString(), store.RestaurantName); //} OptionsGenerator extraMenu = new OptionsGenerator(); extraMenu.Add("b", "Back to UserMenu"); extraMenu.Add("q", "Quit"); double hoursToWait = 1; string userInput; do { Console.Clear(); Console.WriteLine("\n" + PadMiddle($"Store Selection ({currCustomer.Username}) ")); Console.WriteLine("Code".PadRight(10) + "StoreName".PadRight(30) + "WaitTime(hr:min)".PadRight(20) + "DateLastOrdered"); DashPaddings(); Dictionary <int, bool> storeAvailable = new Dictionary <int, bool>(); storeAvailable.Clear(); foreach (Restaurants store in restaurants) { string rID = store.RestaurantId.ToString(); string rName = store.RestaurantName; if (restaurantsRepo.GetLastOrderDate(store.RestaurantId, currCustomer.CustomerId).HasValue) { // has previous order DateTime lastOrder = restaurantsRepo.GetLastOrderDate(store.RestaurantId, currCustomer.CustomerId).Value; TimeSpan timeSinceLastOrder = DateTime.Now - lastOrder; TimeSpan waitTime = DateTime.Now - lastOrder.AddHours(hoursToWait); if (timeSinceLastOrder.TotalHours > hoursToWait) { // time since last order more than an hour from now Console.WriteLine(rID.PadRight(10) + rName.PadRight(30) + "Available".PadRight(20) + lastOrder); storeAvailable.Add(store.RestaurantId, true); } else { // last order was within an hour before Console.WriteLine(rID.PadRight(10) + rName.PadRight(30) + waitTime.ToString(@"hh\:mm").PadRight(20) + lastOrder); storeAvailable.Add(store.RestaurantId, false); } } else { // no previous order Console.WriteLine(rID.PadRight(10) + rName.PadRight(30) + "Available"); storeAvailable.Add(store.RestaurantId, true); } } //storeSelectMenu.DisplayOptions(); DashPaddings(); extraMenu.DisplayOptions(); DashPaddings(); Console.Write("Input: "); userInput = Console.ReadLine(); if (int.TryParse(userInput, out int id)) { // numeric input if (restaurantsRepo.GetRestaurantIDList().Contains(id)) { // Go to that store if (storeAvailable[id]) { restaurantsRepo.SetCurrentRestaurant(id); RestaurantMenu(); } else { // last order is within hoursToWait -> store not available Console.WriteLine("\nStore not available"); Console.ReadKey(true); RestaurantSelectMenu(); } break; } } else if (userInput == "b") { UserMenu(); break; } else if (userInput == "q") { Quit(); return; } }while (userInput != "q"); }