public IActionResult AddReview(Review review) { if (ModelState.IsValid) { _context.Add(review); _context.SaveChanges(); return(RedirectToAction("ShowReviews")); } return(View("ReviewForm")); }
public IActionResult NewReview(Review newReview) { if (ModelState.IsValid) { _context.Add(newReview); _context.SaveChanges(); return(RedirectToAction("Reviews")); } else { return(View("Index")); } }
public IActionResult processForm(Review review) { if (TryValidateModel(review)) { _context.Add(review); _context.SaveChanges(); return(Redirect("reviews")); } else { // REPORT ERRORS Console.WriteLine("ERRORS during validation"); ViewBag.errors = ModelState.Values; return(View("index", review)); } }
public IActionResult Create_Review(Review model) { if (ModelState.IsValid) { Review newReview = new Review { Restaurant_Name = model.Restaurant_Name, Reviewer_Name = model.Reviewer_Name, Reviews = model.Reviews, Visit_Date = model.Visit_Date, Rating = model.Rating }; _context.Add(newReview); _context.SaveChanges(); return(View("Index")); } return(View("Index")); }