public async Task <IActionResult> Edit(int id, [Bind("SessionId,Name,Description,SkillLevel,Keywords,IsApproved,EventId")] Session session) { if (id != session.SessionId) { return(NotFound()); } if (ModelState.IsValid) { //If the user is not an Admin we need to do additional verification if (!User.IsInRole("Admin")) { // Get the user information var currentUser = await _userManager.GetUserAsync(User); var speaker = await _speakerBL.GetSpeaker(currentUser.SpeakerId.Value); //If the user is not the speaker for the session then they should not be able to edit it. if (!_sessionBL.IsSessionEditableBySpeaker(session.SessionId, speaker.SpeakerId)) { return(RedirectToAction(nameof(Index))); } } if (await _sessionBL.UpdateSession(session) == false) { return(NotFound()); } return(RedirectToAction(nameof(Index))); } return(View(session)); }
public async Task <IActionResult> Edit(int id, [Bind("SessionId,Name,Description,SkillLevel,Keywords,IsApproved,EventId")] Session session) { if (id != session.SessionId) { return(NotFound()); } if (ModelState.IsValid) { if (await _sessionBL.UpdateSession(session) == false) { return(NotFound()); } return(RedirectToAction(nameof(Index))); } return(View(session)); }