public ActionResult Edit(InstructorDetailsViewModel model) { var instructor = Mapper.Map <InstructorDetailsViewModel, Instructor>(model); //Person properties _instructorService.EditInstructor(instructor); #region Assign and divest courses var assignedCourses = model.Courses.Where(x => x.IsChecked).Select(x => x.Id).ToList(); var divestedCourses = model.Courses.Where(x => !x.IsChecked).Select(x => x.Id).ToList(); assignedCourses.ForEach(c => _courseInstructorService.AssignInstructorToCourse(instructor.Id, c)); divestedCourses.ForEach(c => _courseInstructorService.DivestInstructorFromCourse(instructor.Id, c)); #endregion return(RedirectToAction("Index")); }