Beispiel #1
0
 public IActionResult CreateReview(Review review)
 {
     review.CreatedAt = DateTime.Now;
     review.UpdatedAt = DateTime.Now;
     _context.Add(review);
     _context.SaveChanges();
     return(RedirectToAction("Reviews"));
 }
Beispiel #2
0
 public IActionResult Add(Review r)
 {
     if (ModelState.IsValid)
     {
         _context.Add(r);
         _context.SaveChanges();
         return(RedirectToAction("ShowReviews"));
     }
     return(View("Index"));
 }
Beispiel #3
0
 public IActionResult addReview(Rest rest)
 {
     if (ModelState.IsValid)
     {
         _context.Add(rest);
         _context.SaveChanges();
         return(RedirectToAction("showreviews"));
     }
     return(View("Index"));
 }
        public IActionResult createReview(Rest newRest)
        {
            if (ModelState.IsValid)
            {
                _context.Add(newRest);
                _context.SaveChanges();

                return(RedirectToAction("Review"));
            }
            return(View("Index"));
        }
Beispiel #5
0
 public IActionResult Create(Reviews review)
 {
     if (ModelState.IsValid)
     {
         _context.Add(review);
         _context.SaveChanges();
         return(RedirectToAction("Result"));
     }
     else
     {
         return(View("Index"));
     }
 }
 public IActionResult Process(Review newReview)
 {
     if (ModelState.IsValid)
     {
         _context.Add(newReview);
         _context.SaveChanges();
         return(RedirectToAction("Reviews"));
     }
     else
     {
         ViewBag.errors = ModelState.Values;
         return(View("Index"));
     }
 }
Beispiel #7
0
        public IActionResult CreateReview(Review review)

        {
            if (ModelState.IsValid)
            {
                System.Console.WriteLine(review);
                review.created_at = DateTime.Now;
                review.updated_at = DateTime.Now;
                _context.Add(review);
                _context.SaveChanges();
                return(RedirectToAction("Reviews"));
            }
            System.Console.WriteLine("ERRORS!");
            return(View("Index"));
        }
Beispiel #8
0
        public IActionResult AddReview(Review newreview)
        {
            Review test = newreview;

            if (ModelState.IsValid)
            {
                if (newreview.date_of_visit > DateTime.Now)
                {
                    ViewBag.error = "Cannot review a future visit";
                    return(RedirectToAction("Index"));
                }
                _context.Add(newreview);
                _context.SaveChanges();
                return(RedirectToAction("Reviews"));
            }
            return(View("Index", newreview));
        }
 public IActionResult AddReview(User user)
 {
     if (user.Date > DateTime.Now)
     {
         ModelState.AddModelError("Date", "Visit must be in the past.");
     }
     if (ModelState.IsValid)
     {
         _context.Add(user);
         _context.SaveChanges();
         return(RedirectToAction("Review"));
     }
     else
     {
         ViewBag.errors = ModelState.Values;
         return(View("Index"));
     }
 }
 public IActionResult Review(Review NewReview)
 {
     if (ModelState.IsValid)
     {
         _context.Add(NewReview);
         _context.SaveChanges();
         TempData["message"] = "You successfully made a review!";
         return(RedirectToAction("Reviews"));
     }
     // TempData["message"] = "You're missing some information!";
     else
     {
         // TempData["errors"] = ModelState.Values;
         // System.Console.WriteLine(ModelState.Values);
         ViewBag.Errors = ModelState.Values;
     }
     return(View("Index"));
     // return RedirectToAction("Index");
 }
        public IActionResult Create(REST rest)
        {
            // REST NewRest = new REST
            // {
            //     Name = rest.Name,
            //     Restaurant = rest.Restaurant,
            //     Review = rest.Review,
            //     Rate = rest.Rate,
            //     Visit = rest.Visit
            // };
            if (ModelState.IsValid)
            {
                _context.Add(rest);
                _context.SaveChanges();
                return(RedirectToAction("Reviews"));
            }


            return(RedirectToAction("Index", rest));
        }
Beispiel #12
0
        public IActionResult AddReview(Review NewReview)
        {
            if (ModelState.IsValid)
            {
                _context.Add(NewReview);
                _context.SaveChanges();
                return(RedirectToAction("Reviews"));
            }

            List <string> allErrors = new List <string>();

            foreach (var i in ModelState.Values)
            {
                if (i.Errors.Count > 0)
                {
                    allErrors.Add(i.Errors[0].ErrorMessage.ToString());
                }
            }
            TempData["Errors"] = allErrors;
            return(RedirectToAction("Index"));
        }
Beispiel #13
0
 public IActionResult AddReview(Review NewReview)
 {
     if (ModelState.IsValid)
     {
         System.Console.WriteLine($"Model is Valid {NewReview}.");
         NewReview.CreatedAt = DateTime.Now;
         NewReview.UpdatedAt = DateTime.Now;
         _context.Add(NewReview);
         _context.SaveChanges();
         //add and commit
         return(RedirectToAction("Show"));
     }
     else
     {
         System.Console.WriteLine("Model is NOT Valid");
         return(View("Index"));
     }
     // System.Console.WriteLine(NewReview);
     // _context.Add(NewReview);
     // _context.SaveChanges();
     // return RedirectToAction("Results");
 }
        public IActionResult NewReview(Review review)
        {
            Review addReview = new Review
            {
                Reviewer   = review.Reviewer,
                Restaurant = review.Restaurant,
                Stars      = review.Stars,
                Reviews    = review.Reviews,
                Visit_Date = review.Visit_Date,
                Created_At = DateTime.Now,
                Updated_At = DateTime.Now,
            };

            TryValidateModel(addReview);
            if (ModelState.IsValid)
            {
                _context.Add(addReview);
                _context.SaveChanges();
                return(RedirectToAction("Home"));
            }
            ViewBag.errors = ModelState.Values;
            return(View("Index"));
        }