コード例 #1
0
        public IList <ClassDetails> GetClassesSortedByPeriod()
        {
            IList <ClassDetails> classes;
            int?teacherId = null;
            int?studentId = null;

            if (Context.RoleId == CoreRoles.TEACHER_ROLE.Id)
            {
                teacherId = Context.PersonId;
                classes   = GetTeacherClasses(Context.SchoolYearId.Value, Context.PersonId.Value);
            }
            else if (Context.RoleId == CoreRoles.STUDENT_ROLE.Id)
            {
                studentId = Context.PersonId;
                classes   = GetStudentClasses(Context.SchoolYearId.Value, Context.PersonId.Value);
            }
            else
            {
                throw new NotImplementedException();
            }

            var schedule = ServiceLocator.ClassPeriodService.GetSchedule(teacherId, studentId, null,
                                                                         Context.NowSchoolYearTime.Date, Context.NowSchoolYearTime.Date).OrderBy(x => x.PeriodOrder);
            var res = new List <ClassDetails>();

            foreach (var classPeriod in schedule)
            {
                var c = classes.FirstOrDefault(x => x.Id == classPeriod.ClassId);
                if (c != null && res.All(x => x.Id != c.Id))
                {
                    res.Add(c);
                }
            }
            classes = classes.Where(x => res.All(y => y.Id != x.Id)).OrderBy(x => x.Name).ToList();


            var l = res.Concat(classes);
            var classDetailses = l as IList <ClassDetails> ?? l.ToList();

            foreach (var cls in classDetailses)
            {
                cls.ClassTeachers = ClassTeacherStorage.GetClassTeachers(cls.Id, null);
            }
            return(classDetailses.ToList());
        }
コード例 #2
0
 public IList <ClassTeacher> GetClassTeachers(int?classId, int?teacherId)
 {
     return(ClassTeacherStorage.GetClassTeachers(classId, teacherId));
 }