Exemplo n.º 1
0
 public ActionResult OrderPizza(
     [ModelBinder(typeof(IngredientsCollectionModelBinder))] PizzaOrderBindingModel pizza)
 {
     // TODO: Proceed to checkout
     // TODO: Multiple orders
     return(this.View());
 }
        public ActionResult OrderPizza([ModelBinder(typeof(PizzaIngredientsModelBinder))] PizzaOrderBindingModel pizza)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.RedirectToAction(nameof(OrderPizza), pizza.PizzaId));
            }

            ShoppingCart shoppingCart = this.Session.GetShoppingCart <ShoppingCart>(UserShoppingCartSessionKey);

            shoppingCart.Pizzas.Add(pizza);

            this.Session.SetShoppingCart(UserShoppingCartSessionKey, shoppingCart);
            TempData.AddSuccessMessage(PizzaAddedToShoppingCart);

            return(this.RedirectToAction(nameof(MenuController.Index), Home));
        }