public ActionResult ReviewSession(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var loggedInUser = _personManager.GetParticipantByCas(User.Identity.Name.ToCasId()); var session = _sessionManager.GetSessionByIdWithIncludes((int)id); if (session == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var currentSessionParticipation = session.SessionParticipants.SingleOrDefault(n => n.ParticipantId == loggedInUser.Id && n.SessionId == id); if (currentSessionParticipation == null) { return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized)); } var reviewSessionViewModel = new ReviewSessionViewModel() { ParticipantId = loggedInUser.Id, ParticipantName = loggedInUser.FullNameWithCas, SessionId = session.Id, SessionName = session.NameWithActivity, Rating = currentSessionParticipation.Rating, Comments = currentSessionParticipation.Comments }; return(View(reviewSessionViewModel)); }
public ActionResult ReviewSession(ReviewSessionViewModel vm) { var loggedInUser = _personManager.GetParticipantByCas(User.Identity.Name.ToCasId()); if (ModelState.IsValid) { if (_personManager.UpdateReviewForSessionParticipant(vm.SessionId, loggedInUser.Id, vm.Rating, vm.Comments)) { return(RedirectToAction("SessionForActivity", "ActivitySummary", new { id = vm.SessionId })); } } return(View(vm)); }