public List<Teacher> GetTeachersFor(List<Group> G, Subject S, int Lab) { if ((G.Count() == 0) || (S == null) || (Lab == -1) || ((G.Count() > 1) && (Lab == 1))) return new List<Teacher>(); List<Teacher> teachers = new List<Teacher>(); List<Load> tmp; if (Lab == 0) tmp = G[0].Loads.Where(l => l.IsLecture).ToList(); else tmp = G[0].Loads.Where(l => l.IsLab).ToList(); var query = from l in tmp where (l.Subject == S) && (l.Semester == this.semester) select l.Teacher; teachers.AddRange(query); return teachers; }
public bool AddReplacemant(List<Group> G, List<Teacher> T, List<Classroom> C, Subject S) { if (selectedLesson == null) { throw new Exception("Немає заняття, що замінюється"); } haveReplacement.Add(selectedLesson); Lesson les = new Lesson{ Day = this.day, Number = this.selectedLesson.Number, Type = this.selectedLesson.Type}; les.Subject = S; message = ""; RefreshFact(); foreach (Group g in G) { var query = fact. Where(l => l.Groups.IndexOf(g) != -1). Where(l => l.Number == les.Number); if (query.Count() > 0) message += g.Title + " "; } foreach (Teacher t in T) { var query = fact. Where(l => l.Teachers.IndexOf(t) != -1). Where(l => l.Number == les.Number); if (query.Count() > 0) message += t.FullName() + " "; } foreach (Classroom c in C) { var query = fact. Where(l => l.Classrooms.IndexOf(c) != -1). Where(l => l.Number == les.Number); if (query.Count() > 0) message += c.Title + " "; } if (message != "") { message = "Зайняті: " + message; return false; } les.Groups = G; les.Teachers = T; les.Classrooms = C; if (!les.IsNormal()) { message = "Помилка"; return false; } replacements.Add(les); currentReplacements.Add(les); return true; }