示例#1
0
        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 });
        }
示例#2
0
        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
                    });
        }