コード例 #1
0
        public ActionResult AddProductReview(string id, ProductReviewAddModel productReview)
        {
            var productReviewAddModel = new ProductReviewAddModel
            {
                Comment                                          = Sanitizer.GetSafeHtmlFragment(productReview.Comment),
                Gender                                           = Sanitizer.GetSafeHtmlFragment(productReview.Gender),
                Location                                         = Sanitizer.GetSafeHtmlFragment(productReview.Location),
                Nickname                                         = Sanitizer.GetSafeHtmlFragment(productReview.Nickname),
                Title                                            = Sanitizer.GetSafeHtmlFragment(productReview.Title),
                UserEmail                                        = Sanitizer.GetSafeHtmlFragment(productReview.UserEmail),
                Rating                                           = productReview.Rating,
                Age                                              = productReview.Age,
                AdditionalData                                   = productReview.AdditionalData,
                IsRecommended                                    = productReview.IsRecommended,
                RemainAnonymous                                  = productReview.RemainAnonymous,
                UserId                                           = _sessionContext.CurrentUser != null?_sessionContext.CurrentUser.UserId.ToString() : null,
                                                  ReviewSections = productReview.ReviewSections
            };

            if (_sessionContext.CurrentUser != null)
            {
                productReviewAddModel.UserEmail = _sessionContext.CurrentUser.Email;
            }
            var response = _productApi.AddProductReview(Sanitizer.GetSafeHtmlFragment(id), productReviewAddModel);

            return(JsonSuccess(response.Result, JsonRequestBehavior.AllowGet));
        }