コード例 #1
0
        public RedirectToRouteResult AddToCart(Сart cart, int Id, string returnUrl)
        {
            var product = _productService.GetAll()
                .FirstOrDefault(p => p.Id == Id);

            if (product != null)
            {
                cart.AddItem(product, 1);
            }

            return RedirectToAction("Index", new { returnUrl });
        }