Exemple #1
0
        private StoneCastle.Scheduler.Models.ClassGroupSchedule GetRandomScheduleGroup(string groupName, int workingShiftInDay)
        {
            TrainingProgramSchedule trainingProgram = new TrainingProgramSchedule()
            {
                Id        = Guid.NewGuid(),
                Timetable = timetableService.GetWorkingTimeTable(this.workingShiftInDay, this.workingSlotPerShift)
                            //Timetable = timetableService.GetTimeTable(this.workingShiftInDay)
            };

            string[] courseSubjectNames = new string[] { "Math", "History", "Geo", "English", "Art", "Literality", "Chemistry" };

            int courseSubjectCount = 0;

            while (courseSubjectCount == 0)
            {
                courseSubjectCount = rand.Next(6);
            }

            for (int i = 0; i < courseSubjectCount; i++)
            {
                CourseSchedule courseSubject = new CourseSchedule()
                {
                    Id = Guid.NewGuid(),
                    //TrainingProgram = trainingProgram,
                    Name           = courseSubjectNames[i],
                    SectionPerWeek = rand.Next(3),
                    HighlightColor = Commons.Ultility.GetHighlightColor(rand),
                };

                trainingProgram.CourseSubjects.Add(courseSubject);
            }

            StoneCastle.Scheduler.Models.ClassGroupSchedule cg = new StoneCastle.Scheduler.Models.ClassGroupSchedule()
            {
                Id              = Guid.NewGuid(),
                Name            = groupName,
                TrainingProgram = trainingProgram
            };

            int classCount = 0;

            while (classCount == 0)
            {
                classCount = rand.Next(6);
            }

            List <StoneCastle.Scheduler.Models.ClassRoomSchedule> classRooms = new List <StoneCastle.Scheduler.Models.ClassRoomSchedule>();

            for (int i = 0; i < classCount; i++)
            {
                StoneCastle.Scheduler.Models.TimetableModel tt = this.timetableService.GetWorkingTimeTable(workingShiftInDay, this.workingSlotPerShift);
                tt = tt.Join(trainingProgram.Timetable);

                StoneCastle.Scheduler.Models.ClassRoomSchedule cr = new StoneCastle.Scheduler.Models.ClassRoomSchedule()
                {
                    Id   = Guid.NewGuid(),
                    Name = $"{groupName}.{(i + 1)}",
                    //ClassGroup = cg,
                    Timetable = tt,
                };

                cg.ClassRooms.Add(cr);
                classRooms.Add(cr);
            }

            // Course
            for (int i = 0; i < courseSubjectCount; i++)
            {
                CourseSchedule courseSubject = ((List <CourseSchedule>)trainingProgram.CourseSubjects)[i];

                StoneCastle.Scheduler.Models.TimetableModel tt = this.timetableService.GetWorkingTimeTable(workingShiftInDay, this.workingSlotPerShift);

                TeacherScheduleModel teacher = new TeacherScheduleModel()
                {
                    Id = Guid.NewGuid(),
                    //FirstName = "Teacher",
                    //LastName = i.ToString(),
                    Timetable = tt
                };

                //for (int j = 0; j < classCount; j++)
                foreach (ClassRoomSchedule classRoom in classRooms)
                {
                    StoneCastle.Scheduler.Models.TimetableModel t = this.timetableService.GetWorkingTimeTable(workingShiftInDay, this.workingSlotPerShift);

                    ClassCourseSchedule course = new ClassCourseSchedule()
                    {
                        Id        = Guid.NewGuid(),
                        Teacher   = teacher,
                        Course    = courseSubject,
                        Timetable = t
                    };

                    classRoom.Courses.Add(course);
                }
            }

            return(cg);
        }