private static IPizza PizzaSizeMenu(IPizza newPizza) { System.Console.WriteLine("Choose Pizza Size: "); DisplayIngredients(PizzaSizeDataRetriever.GetInstance().PizzaSizeList); System.Console.Write("Size Choice: "); int sizeChoice = Convert.ToInt32(Console.ReadLine()); newPizza = new PizzaSizeDecorator(newPizza, PizzaSizeDataRetriever.GetInstance().PizzaSizeList[sizeChoice - 1]); return(newPizza); }
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")); }