using Data.RemoteData.DAO; namespace Data.domain.UseCase { internal class UseCasePresence { private List attendanceRecords; public UseCasePresence(List attendanceRecords) { this.attendanceRecords = attendanceRecords; } public List GetAttendanceByGroup(string groupNumber) { return attendanceRecords.Where(record => record.userDao.Group.GroupName == groupNumber).ToList(); } public List GetAttendanceByGroupAndDate(string groupNumber, DateOnly date) { return attendanceRecords.Where(record => record.userDao.Group.GroupName == groupNumber && record.Date == date).ToList(); } public void MarkUserAsAbsent(string groupNumber, int firstLesson, int lastLesson, DateOnly date) { foreach (var lesson in Enumerable.Range(firstLesson, lastLesson - firstLesson + 1)) { var record = attendanceRecords.FirstOrDefault(r => r.userDao.Group.GroupName == groupNumber && r.LessonNumber == lesson && r.Date == date); if (record != null) { record.IsAttendensy = false; } } } public void MarkUserAsAbsentForWeek(string groupNumber, int firstLesson, int lastLesson, DateOnly startDate) { foreach (var day in Enumerable.Range(0, 7)) { var date = startDate.AddDays(day); MarkUserAsAbsent(groupNumber, firstLesson, lastLesson, date); } } } }