Ejemplo n.º 1
0
 public IActionResult CreateReview(Review review)
 {
     review.created_at = DateTime.Now;
     review.updated_at = DateTime.Now;
     _context.Add(review);
     _context.SaveChanges();
     return(RedirectToAction("Reviews"));
 }
Ejemplo n.º 2
0
 public IActionResult AddAReview(Reviews newReview)
 {
     if (TryValidateModel(newReview))
     {
         if (newReview.isValidDate())
         {
             _context.Add(newReview);
             _context.SaveChanges();
             return(RedirectToAction("Reviews"));
         }
         else
         {
             //Date is too large error..
             string[] err1 = { "Date cannot be in the future." };
             ViewBag.errors = err1;
             return(RedirectToAction("Index"));
         }
     }
     else
     {
         ViewBag.errors = ModelState.Values;
         // return RedirectToAction("Index");
         return(View("Index"));
     }
 }
Ejemplo n.º 3
0
 public IActionResult review(Reviews myreview, string restaurant_name)
 {
     System.Console.WriteLine(myreview);
     System.Console.WriteLine(restaurant_name);
     _dbConnector.review.Add(myreview);
     _dbConnector.SaveChanges();
     return(View("Index"));
 }
Ejemplo n.º 4
0
 public IActionResult addNew(Rating rating)
 {
     if (ModelState.IsValid)
     {
         _context.Add(rating);
         _context.SaveChanges();
         return(RedirectToAction("Reviews"));
     }
     return(View("Index"));
 }
Ejemplo n.º 5
0
 public IActionResult AddReview(Review NewReview)
 {
     if (ModelState.IsValid)
     {
         NewReview.CreatedAt = DateTime.Now;
         NewReview.UpdatedAt = DateTime.Now;
         _context.Add(NewReview);
         _context.SaveChanges();
         return(RedirectToAction("Main"));
     }
     ViewBag.AllErrors = ModelState.Values;
     return(View("AddNew"));
 }
 public IActionResult Submit(ReviewModel submission)
 {
     if (ModelState.IsValid)
     {
         _context.Add(submission);
         _context.SaveChanges();
         return(RedirectToAction("Result"));
     }
     else
     {
         return(View("Index"));
     }
 }
Ejemplo n.º 7
0
 public IActionResult AddReview(Reviewer NewReview)
 {
     if (ModelState.IsValid)
     {
         if (NewReview.VisitDate > DateTime.Today)
         {
             TempData["futuredate"] = "Visit Date cannot be in the future!";
             return(View("Index"));
         }
         _context.Add(NewReview);
         _context.SaveChanges();
         return(RedirectToAction("Reviews"));
     }
     return(View("Index"));
 }
Ejemplo n.º 8
0
        public IActionResult AddRev(REST newREST)
        {
            TryValidateModel(newREST);

            if (ModelState.IsValid)
            {
                _context.Add(newREST);
                _context.SaveChanges();

                List <REST> AllRESTs = _context.RESTauranter.OrderByDescending(x => x.VisitDate).ToList();
                ViewBag.RESTs = AllRESTs;
                return(View("ShowRev"));
            }
            else
            {
                return(View("Index"));
            }
        }
Ejemplo n.º 9
0
 public IActionResult AddReview(Reviews myReview)
 {
     if (ModelState.IsValid)
     {
         // Reviews NewReview = new Reviews
         myReview.created_at = DateTime.Now;
         myReview.updated_at = DateTime.Now;
         if (DateTime.Today < myReview.visitdate)
         {
             ModelState.AddModelError("visitdate", "Visit cannot be in the future, nice try!");
             // TempData["message"] = "LOL, Nice try!";
             return(View("Index"));
         }
         _context.Add(myReview);
         _context.SaveChanges();
         return(RedirectToAction("Reviews"));
     }
     else
     {
         return(View("Index"));
     }
 }