コード例 #1
0
        public RedirectToActionResult RemoveFromCart(int productId, string returnUrl)
        {
            Product product = repository.Products
                              .FirstOrDefault(p => p.ProductID == productId);

            if (product != null)
            {
                CartViewModel cart = GetCart();
                cart.RemoveLine(product);
                SaveCart(cart);
            }
            return(RedirectToAction("Index", new { returnUrl }));
        }