public JsonResult RemoveProductFromShop(int productId, int shopId)
        {
            if (!Request.IsAjaxRequest())
            {
                throw new InvalidCastException("Not an ajax request");
            }

            try
            {
                _shopProductRefRepository.Delete(productId, shopId);
            }
            catch
            {
                return(Json(new { status = "fail" }, "text/html"));
            }

            return(Json(new { status = "success" }, "text/html"));
        }
Esempio n. 2
0
        public ActionResult RemoveProductFromShop(FilterParams filterParams, int shopProductId)
        {
            var shopProduct = _shopProductRefRepository.Read(shopProductId);

            //Verification access
            if (shopProduct == null || (WebSecurity.CurrentUserId != shopProduct.Shop.UserId && !User.IsInRole("Administrator") && !User.IsInRole("Moderator")))
            {
                return(HttpNotFound());
            }

            try
            {
                _shopProductRefRepository.Delete(shopProduct);
            }
            catch
            {
                TempData["error"] = "Произошла ошибка при удалении товара";
            }
            return(RedirectToAction("ProductsShop", filterParams));
        }