Пример #1
0
        public IActionResult LocationSelection(string LocationId)
        {
            // HttpContext.Session.Set("LocationId",BitConverter.GetBytes(Convert.ToUInt32(LocationId)));
            byte [] userArr;
            HttpContext.Session.TryGetValue("activeUser", out userArr);
            User curUser = PizzaBox.Domain.Models.User.ByteArrayToObject(userArr);

            PizzaOrder newOrder = new PizzaOrder(Convert.ToInt32(LocationId), curUser.UserId);

            HttpContext.Session.Set("newOrder", newOrder.ObjectToByteArray());
            return(View("../Pizza/PizzaSelectionPage"));
        }
Пример #2
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"));
        }