// GET: Instructors public async Task <ActionResult> Index(int?id) { var instructorService = new InstructorService(new InstructorRepository(UniversityContext)); if (id != null) { var courses = await instructorService.GetCoursesByInstructor(id.Value); ViewBag.Courses = courses.Select(x => mapper.Map <CourseDTO>(x)); } var instructors = await instructorService.GetAll(); var instructorsDTO = instructors.Select(x => mapper.Map <InstructorDTO>(x)); return(View(instructorsDTO)); }