using System; using System.Collections.Generic; using System.Linq; using Zurnal.Presence namespace Zurnal.Presence { internal class UseCasePresence { private List attendanceRecords; public UseCasePresence(List attendanceRecords) { this.attendanceRecords = attendanceRecords; } public List GetAttendanceByGroup(string groupNumber) { return attendanceRecords.Where(record => record.GroupNumber == groupNumber).ToList(); } public List GetAttendanceByGroupAndDate(string groupNumber, DateTime date) { return attendanceRecords.Where(record => record.GroupNumber == groupNumber && record.Date.Date == date.Date).ToList(); } public void MarkUserAsAbsent(string groupNumber, int firstLesson, int lastLesson, DateTime date) { foreach (var lesson in Enumerable.Range(firstLesson, lastLesson - firstLesson + 1)) { var record = attendanceRecords.FirstOrDefault(r => r.GroupNumber == groupNumber && r.LessonNumber == lesson && r.Date.Date == date.Date); if (record != null) { record.IsPresent = false; } } } } }