예제 #1
0
        public IActionResult PizzaOrderReview()
        {
            byte [] orderArr;
            HttpContext.Session.TryGetValue("newOrder", out orderArr);
            PizzaOrder curOrder = PizzaOrder.ByteArrayToObject(orderArr);

            return(View("PizzaOrderReviewPage", curOrder));
        }
예제 #2
0
        public IActionResult PizzaOrderSubmission(string subButton)
        {
            if (subButton.Equals("Cancel Order!"))
            {
                ViewData["Msg"] = "Order Not Submitted!";
                return(View("OrderSubmissionReceiptPage"));
            }
            else
            {
                byte [] orderArr;
                HttpContext.Session.TryGetValue("newOrder", out orderArr);
                PizzaOrder curOrder = PizzaOrder.ByteArrayToObject(orderArr);

                if (orderDb.SubmitUserOrder(curOrder))
                {
                    ViewData["Msg"] = "Your Order Is Submitted. Happy Meal :)";
                }
                else
                {
                    ViewData["Msg"] = "Can't submit your order. Please, try again latter!!!";
                }
                return(View("OrderSubmissionReceiptPage"));
            }
        }
예제 #3
0
        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"));
        }