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 })); }
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 })); }