Ejemplo n.º 1
0
        public RedirectToActionResult RemoveFromCart(int productId, string returnUrl)
        {
            EShopProduct product = productRepository.Products.FirstOrDefault(p => p.EShopProductId == productId);

            if (product != null)
            {
                Cart cart = GetCart();
                cart.RemoveLine(product);
                SaveCart(cart);
            }
            return(RedirectToAction("Index", new { returnUrl }));
        }
Ejemplo n.º 2
0
        public IActionResult AddtoCart(int Id, string returnUrl)
        {
            EShopProduct eShopProduct = productRepository.Products.FirstOrDefault(x => x.EShopProductId == Id);

            if (eShopProduct != null)
            {
                Cart cart = GetCart();
                cart.AddItem(eShopProduct, 1);
                SaveCart(cart);
            }
            return(RedirectToAction("Index", new { returnUrl }));
        }