Пример #1
0
        public ActionResult Remove(string productId, string returnUrl)
        {
            if (string.IsNullOrEmpty(productId))
            {
                throw new ArgumentException(nameof(productId) + " required");
            }

            if (!basketManager.IsInBasket(User.Identity.GetUserId(), productId))
            {
                throw new InvalidOperationException("Product not in basket");
            }

            basketManager.RemoveFromBasket(User.Identity.GetUserId(), productId);

            if (Url.IsLocalUrl(returnUrl))
            {
                return(Redirect(returnUrl));
            }

            return(RedirectToAction("BasketPage"));
        }