private static void PizzaSelectionMenu() { CurrentPizzaOrder = new PizzaOrder(CurrentShopLocation.ShopID, ActiceUser.UserId); System.Console.WriteLine("Step-2: Pizza(s) Selection: "); bool addMorePizzas = true; while (addMorePizzas) { System.Console.WriteLine("1- Signiture Pizza"); System.Console.WriteLine("2- Custom Pizza"); System.Console.Write("Pizza Choice: "); int pizzaChoice = Convert.ToInt32(Console.ReadLine()); bool pizzaAddedFlag = false; switch (pizzaChoice) { case 1: System.Console.WriteLine("Choose one of the following recipes: "); DisplayPizzaRecipes(PizzaRecipesDataRetriever.GetInstance().PizzaRecipesList); System.Console.Write("Recipe Choice: "); int recipeChoice = Convert.ToInt32(Console.ReadLine()); IPizza newPizza = PizzaRecipesDataRetriever.GetInstance().PizzaRecipesList[recipeChoice - 1]; newPizza = PizzaSizeMenu(newPizza); newPizza = PizzaCrustMenu(newPizza); newPizza = PizzaToppingsMenu(newPizza, 2); pizzaAddedFlag = CurrentPizzaOrder.AddPizzaToOrder(newPizza); break; case 2: IPizza customPizza = new PlainPizza(); customPizza = PizzaSizeMenu(customPizza); customPizza = PizzaCrustMenu(customPizza); customPizza = PizzaToppingsMenu(customPizza, 1); pizzaAddedFlag = CurrentPizzaOrder.AddPizzaToOrder(customPizza); break; } if (pizzaAddedFlag) { System.Console.WriteLine($"Pizza Added. Your order has: {CurrentPizzaOrder.GetTotalPizzaCount()} pizza(s)"); System.Console.WriteLine("Do you want to add more pizzas?"); System.Console.WriteLine("1- Yes 2- No"); System.Console.Write("Add Pizza Choice: "); int addPizzaChoice = Convert.ToInt32(Console.ReadLine()); addMorePizzas = (addPizzaChoice == 1)? true : false; } else { System.Console.WriteLine("Pizza Count/Total Order Cost Limit Reached!!!"); addMorePizzas = false; } } }
public List <PizzaOrder> GetUserOrderHistory(int userID) { List <PizzaOrder> userOrders = new List <PizzaOrder>(); int prevOrder = 0; int currentOrder = 0; var orderList = _dbConnection.PizzasInOrder.Include("Order").Include("Pizza").ToList().Where( p => p.Order.UserId == userID).ToList(); if (orderList.Count == 0) { return(userOrders); } currentOrder = orderList[0].Order.OrderId; foreach (var item in orderList) { currentOrder = item.Order.OrderId; if (prevOrder == currentOrder) { continue; } PizzaOrder ord = new PizzaOrder(item.Order.LocationId, item.Order.UserId, item.Order.OrderId); List <PlainPizza> orderPizzas = new List <PlainPizza>(); for (int i = 0; i < item.Order.PizzasInOrder.ToList().Count; i++) { ord.AddPizzaToOrder(new PlainPizza(item.Order.PizzasInOrder.ToList()[i].Pizza.PizzaCost, item.Order.PizzasInOrder.ToList()[i].Pizza.PizzaDescription)); } userOrders.Add(ord); prevOrder = currentOrder; } return(userOrders); }
public IActionResult AddCustomPizza(string pizzaSizeCode, string pizzaCrustCode, List <string> pizzaToppingCodes) { byte [] orderArr; HttpContext.Session.TryGetValue("newOrder", out orderArr); PizzaOrder curOrder = PizzaOrder.ByteArrayToObject(orderArr); IPizza newPizza = new PlainPizza(); newPizza = new PizzaSizeDecorator(newPizza, PizzaSizeDataRetriever .GetInstance().PizzaSizeList[Convert.ToInt32(pizzaSizeCode)]); newPizza = new PizzaCrustDecorator(newPizza, PizzaCrustDataRetriever .GetInstance().PizzaCrustList[Convert.ToInt32(pizzaCrustCode)]); foreach (var item in pizzaToppingCodes) { newPizza = new PizzaToppingDecorator(newPizza, PizzaToppingsDataRetriever .GetInstance().PizzaToppingsList[Convert.ToInt32(item)]); } bool pizzaAdded = curOrder.AddPizzaToOrder(newPizza); HttpContext.Session.Set("newOrder", curOrder.ObjectToByteArray()); if (pizzaAdded) { ViewData["msg"] = $"Pizza Added. Your order has: {curOrder.GetTotalPizzaCount()} pizza(s)"; } else { ViewData["msg"] = "Pizza Count/Total Order Cost Limit Reached!!!"; } ViewData["orderCount"] = curOrder.GetTotalPizzaCount(); return(View("PizzaSelectionPage")); }