public IList <Student> GetClassStudents(int classId, int?markingPeriodId, bool?isEnrolled = null) { var students = StudentStorage.GetAll(); var stWithDrawDictionary = ServiceLocator.ClassService.GetClassPersons(null, classId, isEnrolled, markingPeriodId) .GroupBy(x => x.PersonRef).ToDictionary(x => x.Key, x => !x.First().IsEnrolled); students = students.Where(s => stWithDrawDictionary.ContainsKey(s.Id)).ToList(); return(PrepareStudentListDetailsData(students, stWithDrawDictionary)); }
public IList <Student> GetTeacherStudents(int teacherId, int schoolYearId) { var students = StudentStorage.GetAll(); var markingPeriods = ServiceLocator.MarkingPeriodService.GetMarkingPeriods(schoolYearId); var classPersons = ((DemoClassService)ServiceLocator.ClassService).GetClassPersonsByMarkingPeriods(markingPeriods); students = students.Where(s => classPersons.Any(cp => cp.PersonRef == s.Id)).ToList(); var stWithDrawDic = ((DemoSchoolYearService)ServiceLocator.SchoolYearService).GetStudentAssignments(schoolYearId, null) .GroupBy(x => x.StudentRef).ToDictionary(x => x.Key, x => !x.First().IsEnrolled); return(PrepareStudentListDetailsData(students, stWithDrawDic)); }
public PaginatedList <Student> SearchStudents(int schoolYearId, int?classId, int?teacherId, int?classmatesToId, string filter, bool orderByFirstName, int start, int count, int?markingPeriod, bool enrolledOnly) { var students = StudentStorage.GetAll().AsEnumerable(); if (!string.IsNullOrEmpty(filter)) { var words = filter.ToLowerInvariant().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); students = students.Where(s => words.Any(w => s.FirstName.ToLower().Contains(w) || s.LastName.ToLower().Contains(w))); } var classTeachers = ServiceLocator.ClassService.GetClassTeachers(classId, teacherId); var markingPeriods = ServiceLocator.MarkingPeriodService.GetMarkingPeriods(schoolYearId); var stSchoolYears = ((DemoSchoolYearService)ServiceLocator.SchoolYearService).GetStudentAssignments(schoolYearId, null); var classPersons = ((DemoClassService)ServiceLocator.ClassService).GetClassPersons(classId); classPersons = classPersons.Where(x => classTeachers.Any(y => y.ClassRef == x.ClassRef)).ToList(); classPersons = classPersons.Where(x => markingPeriods.Any(y => y.Id == x.MarkingPeriodRef)).ToList(); students = students.Where(x => classPersons.Any(y => y.PersonRef == x.Id)); students = students.Where(x => stSchoolYears.Any(y => y.StudentRef == x.Id)); students = orderByFirstName ? students.OrderBy(s => s.FirstName) : students.OrderBy(s => s.LastName); var res = students.ToList(); IDictionary <int, bool> stWithDrawDic = new Dictionary <int, bool>(); foreach (var student in res) { var isEnrolled = stSchoolYears.Any(x => x.StudentRef == student.Id && x.IsEnrolled) && classPersons.Any(x => x.PersonRef == student.Id && x.IsEnrolled); if (!stWithDrawDic.ContainsKey(student.Id)) { stWithDrawDic.Add(student.Id, !isEnrolled); } else { stWithDrawDic[student.Id] = !isEnrolled; } } return(new PaginatedList <Student>(PrepareStudentListDetailsData(res, stWithDrawDic), start / count, count)); }
// GET: Student public ActionResult Index() { return(View(StudentStorage.GetAll())); }