示例#1
0
 public IActionResult AddReview(Review newreview)
 {
     if (ModelState.IsValid)
     {
         _context.Add(newreview);
         _context.SaveChanges();
         List <Review> AllReviews = _context.reviews.OrderByDescending(a => a.VisitDate).ToList();
         ViewBag.allreviews = AllReviews;
         return(View("Index"));
     }
     return(View("New"));
 }
示例#2
0
 public IActionResult Create(Review model)
 {
     if (ModelState.IsValid)
     {
         Review newReview = new Review
         {
             ReviewerName   = model.ReviewerName,
             RestaurantName = model.RestaurantName,
             Comment        = model.Comment,
             Rating         = model.Rating,
             Visited        = model.Visited,
             CreatedAt      = DateTime.Now,
             UpdatedAt      = DateTime.Now
         };
         _restContext.Add(newReview);
         _restContext.SaveChanges();
         return(RedirectToAction("Reviews"));
     }
     return(View("Index"));
 }
        public IActionResult Create(Review review)
        {
            if (!ModelState.IsValid)
            {
                return(View("Index"));
            }
            else
            {
                Review NewReview = new Review
                {
                    ReviewerName = review.ReviewerName,
                    RestName     = review.RestName,
                    RestReview   = review.RestReview,
                    VisitDate    = review.VisitDate,
                    Rating       = review.Rating
                };

                _context.Add(NewReview);
                _context.SaveChanges();
                return(RedirectToAction("Show"));
            }
        }
 public void Post([FromBody] Creds entity)
 {
     entity.Key = Helper.OneWayHash(entity.Key);
     _RESTContext.Add(entity);
     _RESTContext.SaveChanges();
 }
示例#5
0
 public IActionResult AddRev(Review rev)
 {
     _context.Add(rev);
     _context.SaveChanges();
     return(RedirectToAction("Reviews"));
 }