Exemple #1
0
        public async Task <IActionResult> Edit(ProductReviewModel model, bool continueEditing)
        {
            var productReview = await _productReviewService.GetProductReviewById(model.Id);

            if (productReview == null)
            {
                //No product review found with the specified id
                return(RedirectToAction("List"));
            }

            if (_workContext.CurrentCustomer.IsStaff() && productReview.StoreId != _workContext.CurrentCustomer.StaffStoreId)
            {
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                productReview = await _productReviewViewModelService.UpdateProductReview(productReview, model);

                SuccessNotification(_localizationService.GetResource("Admin.Catalog.ProductReviews.Updated"));
                return(continueEditing ? RedirectToAction("Edit", new { id = productReview.Id, ProductId = productReview.ProductId }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            await _productReviewViewModelService.PrepareProductReviewModel(model, productReview, true, false);

            return(View(model));
        }
Exemple #2
0
        public IActionResult Edit(ProductReviewModel model, bool continueEditing, [FromServices] IProductService productService)
        {
            var productReview = productService.GetProductReviewById(model.Id);

            if (productReview == null)
            {
                //No product review found with the specified id
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                productReview = _productReviewViewModelService.UpdateProductReview(productReview, model);
                SuccessNotification(_localizationService.GetResource("Admin.Catalog.ProductReviews.Updated"));
                return(continueEditing ? RedirectToAction("Edit", new { id = productReview.Id, ProductId = productReview.ProductId }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            _productReviewViewModelService.PrepareProductReviewModel(model, productReview, true, false);
            return(View(model));
        }