Пример #1
0
        public IActionResult FacilitatorCourses(string userId)
        {
            var courses = _coursesRepository.GetCourseByFacilitatorId(userId).ToList();
            var model   = _mapper.Map <List <CourseVM> >(courses);

            return(View(model));
        }
        // This method removes a user from the facilitator role
        public IActionResult RemoveFromFacilitatorRole(string id)
        {
            var facilitator = _userManager.FindByIdAsync(id).Result;
            var result      = _userManager.RemoveFromRoleAsync(facilitator, "Facilitator").Result;

            if (result.Succeeded)
            {
                var facilitatorCourse = _coursesRepository.GetCourseByFacilitatorId(id);
                foreach (var item in facilitatorCourse)
                {
                    item.FacilitatorId = null;
                    _coursesRepository.Update(item);
                }
                return(RedirectToAction("FacilitatorsList"));
            }
            return(View("Error", "Home"));
        }