Exemplo n.º 1
0
 public Group(string id, string lecturer, GroupEvent groupEvent) : this(id, lecturer, new[] { groupEvent })
 {
 }
Exemplo n.º 2
0
 public TimeSlot(GroupEvent groupEvent)
 {
     Events = new List <GroupEvent> {
         groupEvent
     };
 }
        private List <Course> CreateCourses(Dictionary <string, List <ParsedCourseRow> > courseIdToRows)
        {
            var courses = new List <Course>(courseIdToRows.Keys.Count);

            foreach (var courseGroupsRows in courseIdToRows)
            {
                var courseId = courseGroupsRows.Key;

                var mainLecture = courseGroupsRows.Value.First();

                var mainLecturer   = mainLecture.Lecturer;
                var courseName     = mainLecture.GroupName;
                var academicPoints = mainLecture.AcademicPoints;

                var courseClassTypes = new List <ClassType>();

                // traverse course class-type
                foreach (var classType in courseGroupsRows.Value.GroupBy(g => g.ClassType))
                {
                    var classTypeName = classType.Key;

                    var courseGroups = new List <Group>();

                    // traverse class-type groups
                    foreach (var classTypeGroups in classType.GroupBy(x => string.IsNullOrEmpty(x.SubGroup) ? x.Group : $"{x.SubGroup}/{x.Group}"))
                    {
                        var courseGroupId = classTypeGroups.Key;

                        var courseGroupEvents = new List <GroupEvent>(3);
                        var lecturer          = classTypeGroups.First().Lecturer;

                        // traverse class-type group events
                        foreach (var groupEvent in classTypeGroups)
                        {
                            var day       = groupEvent.DayOfWeek;
                            var startHour = groupEvent.StartHour;
                            var endHour   = groupEvent.EndHour;
                            var room      = groupEvent.Room;

                            var courseGroupEvent = new GroupEvent(day, startHour, endHour, room);
                            courseGroupEvents.Add(courseGroupEvent);
                        }

                        if (courseGroupEvents.Any())
                        {
                            courseGroupEvents.Sort();
                            var courseGroup = new Group(courseGroupId, lecturer, courseGroupEvents.ToArray());
                            courseGroups.Add(courseGroup);
                        }
                    }

                    if (courseGroups.Any())
                    {
                        var isMandatory     = classTypeName != "סדנה";
                        var courseClassType = new ClassType(classTypeName, courseGroups, isMandatory);
                        courseClassTypes.Add(courseClassType);
                    }
                }

                if (courseClassTypes.Any())
                {
                    var course = new Course(courseId, courseName, mainLecturer, academicPoints, courseClassTypes);
                    courses.Add(course);
                }
            }

            PopulateReferences(courses);

            return(courses);
        }