public RedirectToActionResult RemoveFromCart(int productId, string returnUrl) { Product p = reprository.Products.FirstOrDefault(s => s.ProductID == productId); if (p != null) { Cartt c = GetCart(); c.RemoveLine(p); SaveCart(c); } return(RedirectToAction("Index", new { returnUrl })); }
private void SaveCart(Cartt cart) { HttpContext.Session.SetJson("Cart", cart); }
private Cartt GetCart() { Cartt cart = HttpContext.Session.GetJson <Cartt>("Cart") ?? new Cartt(); return(cart); }