// GET: Subject public ActionResult Index() { teacherService = new TeacherService(); studentService = new StudentService(); subjectService = new SubjectService(); List <Subject> allSubjects = subjectService.getAllSubjects(); IEnumerable <Teacher> teachers = teacherService .GetTeacherNamesFromListOfSubjects(allSubjects); List <int> numberOfStudentsEnrolled = studentService.GetNumberOfStudentsEnrolledInASubject(allSubjects); List <TeacherSubjectNumberOfStudentsViewModel> viewModel = subjectService .CreateTeacherSubjectNumberOfStudentsViewModel (allSubjects.ToArray(), teachers.ToArray(), numberOfStudentsEnrolled.ToArray()); return(View(viewModel)); }