Ejemplo n.º 1
0
        public int AddProductReviewV2(string loginId, string memberName, int productNo, string productCode, string productName, int displayCategoryNo, string title, string contents, int priceRate, int designRate, int qualityRate, int deliveryRate, string CommentImage)
        {
            var data = new AddProductReviewModel
            {
                LoginId           = loginId,
                CommentImage      = CommentImage,
                Contents          = contents,
                DeliveryRate      = deliveryRate,
                DesignRate        = designRate,
                DisplayCategoryNo = displayCategoryNo,
                MemberName        = memberName,
                PriceRate         = priceRate,
                ProductCode       = productCode,
                ProductName       = productName,
                ProductNo         = productNo,
                QualityRate       = qualityRate,
                Title             = title
            };

            var response = GetDataFromApiOut <BaseResultAPI <int>, AddProductReviewModel>(
                "Product/AddProductReviewV2",
                Method.POST,
                null,
                null,
                data);

            return(response.Data);
        }
Ejemplo n.º 2
0
        protected AddProductReviewModel PrepareAddProductReviewModel(ProductOverviewModel product)
        {
            var model = new AddProductReviewModel
            {
                Name   = string.IsNullOrWhiteSpace(product.H1Title) ? product.Name : product.H1Title,
                UrlKey = product.UrlKey
            };

            model.ProductBox        = product.PrepareProductBoxModel();
            model.ProductBreadcrumb = PrepareProductBreadcrumbModel(product.Id);

            return(model);
        }
Ejemplo n.º 3
0
        public ActionResult AddProductReview(int productId, AddProductReviewModel model)
        {
            if (_workContext.CurrentProfile.IsAnonymous)
            {
                return(new HttpUnauthorizedResult());
            }

            var product = _productService.GetProductOverviewModelById(productId);

            //TODO: I think we should redirect to a page that recommends other related products instead.
            // If the product is offline, then return 404
            if (product == null || product.Enabled == false || product.VisibleIndividually == false)
            {
                return(InvokeHttp404());
            }

            if (ModelState.IsValid)
            {
                var review = new ProductReview
                {
                    ProductId   = product.Id,
                    ProfileId   = _workContext.CurrentProfile.Id,
                    Alias       = model.Alias,
                    Title       = model.Title,
                    Comment     = model.Comment,
                    Score       = model.Rating,
                    TimeStamp   = DateTime.Now,
                    ProductName = product.Name
                };

                _productService.InsertProductReview(review);

                model = PrepareAddProductReviewModel(product);
                model.SuccessfullyAdded = true;
                model.Result            = "You will see the product review after approving by a store administrator.";

                return(View(model));
            }

            return(View(model));
        }
 public ProductReviewEvent(Product product, AddProductReviewModel productReview)
 {
     Product       = product;
     ProductReview = productReview;
 }