public async Task <ActionResult> Rate(ParkRatingCreate model) { if (ModelState.IsValid) { var service = new RatingService(User.Identity.GetUserId()); if (await service.CreateParkRatingAsync(model)) { return(RedirectToAction("Index")); } } return(View(model)); }
public async Task <ActionResult> Rate(int id) { var service = GetParkService(); ViewBag.Detail = await service.GetParkByIdAsync(id); var model = new ParkRatingCreate { ParkId = id }; return(View()); }
//Rate a Park public async Task <bool> CreateParkRatingAsync(ParkRatingCreate model) { var entity = new ParkRating { Description = model.Description, ParkId = model.ParkId, Score = model.Score, VisitDate = model.VisitDate, UserId = _userId, }; _context.Ratings.Add(entity); var changeCount = await _context.SaveChangesAsync(); return(changeCount == 1); }