public async Task <IActionResult> Edit(int?id)
        {
            if (!id.HasValue)
            {
                return(NotFound());
            }

            var session = await _sessionBL.GetSession(id.Value);

            if (session == null)
            {
                return(NotFound());
            }

            //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)));
                }
            }

            ViewBag.SkillLevels = SkillLevel.GetSkillLevels();
            return(View(session));
        }
Пример #2
0
        // GET: Sessions/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (!id.HasValue)
            {
                return(NotFound());
            }

            var session = await _sessionBL.GetSession(id.Value);

            if (session == null)
            {
                return(NotFound());
            }

            ViewBag.SkillLevels = SkillLevel.GetSkillLevels();
            return(View(session));
        }
 // GET: Sessions/Create
 public IActionResult Create()
 {
     ViewBag.SkillLevels = SkillLevel.GetSkillLevels();
     return(View());
 }