public ActionResult StudentsEnrolled(int id, bool?error) { if (Session["userId"] == null) { return(RedirectToAction("Index", "Home")); } ViewBag.Email = Session["email"]; if (error == true) { ModelState.AddModelError("prag_error", "Nemoguće unjeti više bodova od maksimalnog broj bodova po komponenti!"); } var courseServices = new CourseServices(_courseRepository, _userRepository, _componentRepository); var course = courseServices.GetCourseById(id); ViewBag.Title = course.Name; var studentServices = new StudentServices(_userRepository); var scoreServices = new ScoreServices(_scoreRepository, _courseRepository, _userRepository); IList <Student> enrolledStudents = studentServices.GetStudentsByCourse(course); IList <StudentEnrollementViewModel> enroll = new List <StudentEnrollementViewModel>(); foreach (Student s in enrolledStudents) { IList <Score> score = scoreServices.GetScorebyStudentAndCourse(s.Id, course.Id); enroll.Add(new StudentEnrollementViewModel(score)); } return(View(enroll)); }