public StudentAttendanceSummary GetStudentAttendanceSummary(int studentId, int?gradingPeriodId) { DateTime startDate, endDate; ((DemoGradingPeriodService)ServiceLocator.GradingPeriodService).GetDateRangeByGpID(gradingPeriodId, out startDate, out endDate); var syId = ServiceLocator.SchoolYearService.GetCurrentSchoolYear().Id; var student = ServiceLocator.StudentService.GetById(studentId, syId); var classes = ServiceLocator.ClassService.GetStudentClasses(syId, studentId); var sectionSummaries = GetSectionAttendanceSummary(studentId, startDate, endDate); var res = new StudentAttendanceSummary { Student = student, ClassAttendanceSummaries = new List <StudentClassAttendanceSummary>() }; foreach (var classDetailse in classes) { var sectionSummay = sectionSummaries.FirstOrDefault(x => x.SectionId == classDetailse.Id); if (sectionSummay != null) { var studentSectionSummary = sectionSummay.Students.FirstOrDefault(s => s.StudentId == studentId && s.SectionId == classDetailse.Id); if (studentSectionSummary == null) { continue; } res.ClassAttendanceSummaries.Add(StudentClassAttendanceSummary.Create(studentSectionSummary, classDetailse)); } } return(res); }
public StudentAttendanceSummary GetStudentAttendanceSummary(int studentId, int?gradingPeriodId) { var syId = ServiceLocator.SchoolYearService.GetCurrentSchoolYear().Id; var student = ServiceLocator.StudentService.GetById(studentId, syId); var stiModel = ConnectorLocator.StudentConnector.GetStudentAttendanceSummary(studentId, syId, gradingPeriodId); int?mpId = null; if (gradingPeriodId.HasValue) { var gp = ServiceLocator.GradingPeriodService.GetGradingPeriodById(gradingPeriodId.Value); mpId = gp.MarkingPeriodRef; } var classes = ServiceLocator.ClassService.GetStudentClasses(syId, studentId, mpId); var res = new StudentAttendanceSummary { Student = student }; if (stiModel != null) { if (stiModel.DailyAttendance != null) { res.DailyAttendanceSummary = StudentDailyAttendanceSummary.Create(stiModel.DailyAttendance); } if (stiModel.PeriodAttendance != null) { res.ClassAttendanceSummaries = StudentClassAttendanceSummary.Create(stiModel.PeriodAttendance.ToList(), classes); } } return(res); }