diff --git a/TeachersTimetable/Services/ParseService.cs b/TeachersTimetable/Services/ParseService.cs index 7de4bf4..ca092c6 100644 --- a/TeachersTimetable/Services/ParseService.cs +++ b/TeachersTimetable/Services/ParseService.cs @@ -160,7 +160,10 @@ public async Task ParseDay() teacherInfo.Lessons.RemoveRange(0, count); teacherInfo.Lessons.Reverse(); - if (teacherInfo.Lessons.Count < 1) + var teacherInfoFromTimetable = + Timetable.LastOrDefault()?.TeacherInfos.FirstOrDefault(t => t.Name == teacherInfo.Name); + if (teacherInfo.Lessons.Count < 1 && teacherInfoFromTimetable is not null && + teacherInfoFromTimetable.Lessons.Count > 0) { notificationUsersList.AddRange((await this._mongoService.Database.GetCollection("Users") .FindAsync(u => u.Teacher != null && u.Notifications && u.Teacher == teacherInfo.Name)).ToList()); @@ -178,8 +181,6 @@ public async Task ParseDay() } teacherInfo.Lessons = teacherInfo.Lessons.OrderBy(l => l.Index).ToList(); - var teacherInfoFromTimetable = - Timetable.LastOrDefault()?.TeacherInfos.FirstOrDefault(t => t.Name == teacherInfo.Name); if (teacherInfoFromTimetable is null || teacherInfoFromTimetable.Equals(teacherInfo)) continue; teacherUpdatedList.Add(teacherInfo.Name);