Exemplo n.º 1
0
        public IList <ClassStatsInfo> GetClassesStats(int schoolYearId, int?start, int?count, string filter, int?teacherId, ClassSortType?sortType)
        {
            start = start ?? 0;
            count = count ?? int.MaxValue;
            var iNowSortType = EnumMapperFactory.GetMapper <ClassSortType, SectionSummarySortOption>().Map(sortType ?? ClassSortType.ClassAsc);

            IList <SectionSummary> iNowRes;

            try
            {
                if (teacherId.HasValue)
                {
                    iNowRes = ConnectorLocator.ClassesDashboardConnector.GetSectionSummariesByTeacher(schoolYearId,
                                                                                                      teacherId.Value, Context.NowSchoolYearTime, start.Value + 1, start.Value + count.Value, filter, iNowSortType);
                }
                else
                {
                    iNowRes = ConnectorLocator.ClassesDashboardConnector.GetSectionsSummaries(schoolYearId,
                                                                                              Context.NowSchoolYearTime, start.Value + 1, start.Value + count.Value, filter, iNowSortType);
                }
            }
            catch (ChalkableSisNotSupportVersionException)
            {
                var chalkableRes = DoRead(u => new ClassDataAccess(u).GetClassesBySchoolYear(schoolYearId, start.Value, count.Value,
                                                                                             filter, teacherId, (int?)sortType));
                return(chalkableRes.Select(ClassStatsInfo.Create).ToList());
            }

            using (var u = Read())
            {
                var classesIds    = iNowRes.Select(x => x.SectionId).ToList();
                var classes       = new ClassDataAccess(u).GetByIds(classesIds);
                var classTeachers = new ClassTeacherDataAccess(u).GetClassTeachers(classesIds);

                return(ClassStatsInfo.Create(iNowRes, classes, classTeachers));
            }
        }
Exemplo n.º 2
0
        public IList <TeacherStatsInfo> GetTeachersStats(int schoolYearId, string filter, int?start, int?count, TeacherSortType?sortType)
        {
            start = start ?? 0;
            count = count ?? int.MaxValue;
            var iNowSortType = EnumMapperFactory.GetMapper <TeacherSortType, SectionSummarySortOption>()
                               .Map(sortType ?? TeacherSortType.TeacherAsc);

            try
            {
                var iNowRes = ConnectorLocator.ClassesDashboardConnector.GetTeachersSummaries(schoolYearId,
                                                                                              Context.NowSchoolYearTime, start.Value + 1, start.Value + count.Value, filter, iNowSortType);

                return(iNowRes.Select(TeacherStatsInfo.Create).ToList());
            }
            catch (ChalkableSisNotSupportVersionException)
            {
                using (var u = Read())
                {
                    var teachers = new StaffDataAccess(u).GetShortStaffSummary(schoolYearId, filter, start.Value, count.Value, (int?)sortType);
                    var classes  = new ClassDataAccess(u).GetClassesByTeachers(schoolYearId, teachers.Select(x => x.Id).ToList());
                    return(TeacherStatsInfo.Create(teachers, classes));
                }
            }
        }