public RedirectToRouteResult AddToCart(Cart cart, int spareId, string returnUrl) { SparePart sparepart = db.SpareParts .FirstOrDefault(e => e.Id == spareId); if (sparepart != null) { cart.AddItem(sparepart, 1); } return RedirectToAction("Index", new { returnUrl }); }
public virtual ActionResult AddToCart(Cart cart, int spareId, string returnUrl) { SparePart sparepart = _db.FindById(spareId); if (sparepart != null) { cart.AddItem(sparepart, 1); } return View(Views.Index, new CartIndexViewModel { Cart = cart, ReturnUrl = returnUrl }); }