public IActionResult CreateReview(ReviewEditModel model) { if (ModelState.IsValid) { int stars = 0; stars = Star(stars, model.One); stars = Star(stars, model.Two); stars = Star(stars, model.Three); stars = Star(stars, model.Four); stars = Star(stars, model.Five); var newReview = new Review(); newReview.Name = model.Name; newReview.Text = model.Text; newReview.UserId = User.FindFirst(ClaimTypes.NameIdentifier).Value; newReview.Stars = stars; newReview.restaurantId = model.Restaurant; newReview = _reviewData.Add(newReview); return(RedirectToPage("/Shared/ReviewPage")); } else { return(View()); } }
public IActionResult Create(ReviewCreateViewModel model, int id) { if (ModelState.IsValid) { var newReview = new Review(); newReview.Comment = model.Comment; newReview.RestaurantId = id; newReview.UserName = User.Identity.Name; newReview.Rating = model.Rating; newReview.Date = model.Date; newReview = _reviewdata.Add(newReview); _reviewdata.Commit(); return(RedirectToAction("Details", new { id = newReview.Id })); } return(View()); }