Пример #1
0
 public IActionResult AddReview(Review review)
 {
     if (ModelState.IsValid)
     {
         _context.Add(review);
         _context.SaveChanges();
         return(RedirectToAction("ShowReviews"));
     }
     return(View("ReviewForm"));
 }
Пример #2
0
 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));
     }
 }
Пример #4
0
        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"));
        }