public static object[,] GetTimetables(int userid) { UserLogDAO.Insert(userid, "gettbs{}"); TimetableField[] fields = new TimetableField[] { TimetableField.Id, TimetableField.Name, TimetableField.Status }; return(TimetableDAO.Select(fields, new SqlQueryCondition(TimetableField.Owner, SqlQueryConditionOperator.Equal, userid))); }
public static Timetable MergeToTimetable(Timetable t, TimetableAcademicYear d) { //adding event to the timetable tree if (t.AcademicYears.Exists(e => e.AcademicYear == d.AcademicYear)) { TimetableAcademicYear nextLayerTimetable = t[d.AcademicYear].First(); TimetableDepartment nextLayerK0 = d.Departments[0]; if (nextLayerTimetable.Departments.Exists(e => e.Department == nextLayerK0.Department)) { TimetableDepartment nextLayerTimetable1 = nextLayerTimetable[nextLayerK0.Department].First(); TimetableMode nextLayerK1 = nextLayerK0.Modes[0]; if (nextLayerTimetable1.Modes.Exists(e => e.Mode == nextLayerK1.Mode)) { TimetableMode nextLayerTimetable2 = nextLayerTimetable1[nextLayerK1.Mode].First(); TimetableField nextLayerK2 = nextLayerK1.Fields[0]; if (nextLayerTimetable2.Fields.Exists(e => e.FieldOfStudy == nextLayerK2.FieldOfStudy)) { TimetableField nextLayerTimetable3 = nextLayerTimetable2[nextLayerK2.FieldOfStudy].First(); TimetableSemester nextLayerK3 = nextLayerK2.Semesters[0]; if (nextLayerTimetable3.Semesters.Exists(e => e.Semester == nextLayerK3.Semester && e.Degree == nextLayerK3.Degree)) { TimetableSemester nextLayerTimetable4 = nextLayerTimetable3[nextLayerK3.Semester, nextLayerK3.Degree, nextLayerK3.Year].First(); TimetableDay nextLayerK4 = nextLayerK3.Days[0]; if (nextLayerTimetable4.Days.Exists(e => e.DayOfWeek == nextLayerK4.DayOfWeek)) { //TimetableDay nextLayerTimetable5 = nextLayerTimetable4[nextLayerK4.DayOfWeek].First(); //nextLayerTimetable5.Events.AddRange(nextLayerK4.Events); TimetableDay nextLayerTimetable5 = nextLayerTimetable4[nextLayerK4.DayOfWeek].First(); TimetableEvent nextLayerK5 = nextLayerK4.Events[0]; if (nextLayerTimetable5.Events.Any(e => e.EqualsExceptGroups(nextLayerK5))) { TimetableEvent nextLayerTimetable6 = nextLayerTimetable5.Events.Find(e => e.EqualsExceptGroups(nextLayerK5)); nextLayerTimetable6.Groups = nextLayerTimetable6.Groups.Union(nextLayerK5.Groups).ToList(); nextLayerTimetable6.FacultyGroups = nextLayerTimetable6.FacultyGroups.Union(nextLayerK5.FacultyGroups).ToList(); } else { nextLayerTimetable5.Events.Add(nextLayerK5); } } else { nextLayerTimetable4.Days.Add(nextLayerK4); } } else { nextLayerTimetable3.Semesters.Add(nextLayerK3); } } else { nextLayerTimetable2.Fields.Add(nextLayerK2); } } else { nextLayerTimetable1.Modes.Add(nextLayerK1); } } else { nextLayerTimetable.Departments.Add(nextLayerK0); } } else { t.AcademicYears.Add(d); } return(t); }