public ActionResult Rate(int id) { var service = CreateCenterService(); ViewBag.Detail = service.GetCenterById(id); var model = new CenterRatingCreate { CenterId = id }; return(View(model)); }
//Rate a center public bool CreateCenterRating(CenterRatingCreate model) { var entity = new CenterRating { Description = model.Description, CenterId = model.CenterId, MyRating = model.MyRating, VisitDate = model.VisitDate, UserId = _userId.ToString() }; using (var ctx = new ApplicationDbContext()) { ctx.Ratings.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Rate(CenterRatingCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = new RatingService(Guid.Parse(User.Identity.GetUserId())); if (service.CreateCenterRating(model)) { TempData["SaveResult"] = "Your rating was added."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Rating could not be added."); return(View(model)); }