コード例 #1
0
 private static IDailyStatsHandler GetDailStatsHandler(DatePeriodTypeEnum datePeriodType)
 {
     if (!handlers.ContainsKey(datePeriodType))
     {
         throw new ChalkableException("Invalid date period type");
     }
     return(handlers[datePeriodType]);
 }
コード例 #2
0
        public static async Task <ClassDisciplineSummaryViewData> GetClassDisciplineSummary(int classId, DatePeriodTypeEnum datePeriodType, IServiceLocatorSchool serviceLocator)
        {
            DateTime startDate, endDate;
            var      handler = GetDailStatsHandler(datePeriodType);

            handler.GetDateRange(out startDate, out endDate, serviceLocator);
            var disciplineDailySummaries = await serviceLocator.DisciplineService.GetClassDisciplineDailySummary(classId, startDate, endDate);

            var stats = disciplineDailySummaries.ToDictionary(x => x.Date, x => (decimal)x.Occurrences);

            return(ClassDisciplineSummaryViewData.Create(classId, datePeriodType, handler.BuildDailyStats(stats, startDate, endDate)));
        }
コード例 #3
0
        public static async Task <ClassAttendanceSummaryViewData> GetClassAttendanceSummary(int classId, DatePeriodTypeEnum datePeriodType, IServiceLocatorSchool serviceLocator)
        {
            DateTime startDate, endDate;
            var      handler = GetDailStatsHandler(datePeriodType);

            handler.GetDateRange(out startDate, out endDate, serviceLocator);
            var attSummaries = await serviceLocator.AttendanceService.GetDailyAttendanceSummaries(classId, startDate, endDate);

            var absences = handler.BuildDailyStats(attSummaries.ToDictionary(x => x.Date, x => x.Absences ?? 0), startDate, endDate);
            var lates    = handler.BuildDailyStats(attSummaries.ToDictionary(x => x.Date, x => (decimal)(x.Tardies ?? 0)), startDate, endDate);
            var presents = handler.BuildDailyStats(attSummaries.ToDictionary(x => x.Date, x => x.Presents ?? 0), startDate, endDate);

            return(ClassAttendanceSummaryViewData.Create(classId, datePeriodType, absences, lates, presents));
        }