public ActionResult Create(FormCollection collection) { try { var productReview = reviewService.GetProductReview(collection["productId"]); if(productReview == null) { productReview = new ProductReview(); productReview.ProductID = collection["productId"]; } var review = new Review(); review.FullComment = collection["comment"]; review.DesignRating = double.Parse(collection["designRating"]); review.ValueRating = double.Parse(collection["valueRating"]); review.QualityRating = double.Parse(collection["qualityRating"]); review.UserNickname = "Anonymous"; productReview.Reviews.Add(review); dynamic product = new ExpandoObject(); product.ID = collection["productId"]; var model = new PageModel() { Review = productReview, Product = product }; reviewService.Save(productReview); return PartialView("Ajax/Index", model); } catch { return View(); } }
public void Save(ProductReview productReview) { mongoService .GetCollection<ProductReview>("productReviews") .Save(productReview); }