Exemple #1
0
        public IActionResult Cart(UserViewModel uvm)
        {
            Pizza pizza = _ps.GetPizzaFake(uvm.PizzaID);

            if (pizza != null)
            {
                List <Pizza> cart = SessionSerializer.FromJson <List <Pizza> >(HttpContext.Session, "Cart");
                if (cart == null)
                {
                    cart = new List <Pizza>();
                }
                cart.Add(pizza);
                SessionSerializer.ToJson(HttpContext.Session, "Cart", cart);
            }
            return(Redirect("/User/Order"));
        }
Exemple #2
0
        public IActionResult Topping(PizzaViewModel pvm)
        {
            Topping topping = _ps.GetTopping(pvm.ToppingID);

            if (topping != null)
            {
                List <Topping> toppings = SessionSerializer.FromJson <List <Topping> >(HttpContext.Session, "Toppings");
                if (toppings == null)
                {
                    toppings = new List <Topping>();
                }
                toppings.Add(topping);
                SessionSerializer.ToJson(HttpContext.Session, "Toppings", toppings);
            }
            HttpContext.Session.SetString("CrustID", pvm.CrustID.ToString());
            HttpContext.Session.SetString("SizeID", pvm.SizeID.ToString());
            return(Redirect("/Pizza/Create"));
        }