Example #1
0
        public ActionResult AddToShoppingCartCommand(int productId, int quantity = 1)
        {
            var cart = RetrieveCurrentShoppingCart();

            cart = _service.AddProductToShoppingCart(cart, productId, quantity);
            SaveCurrentShoppingCart(cart);

            // PRG (Post-Redirect-Get) pattern to avoid F5 refresh issues
            // (and also key step to neatly separate Commands from Queries in the future)
            return(RedirectToAction("AddTo"));
        }