diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index 015932d..ea9ac80 100644 Binary files a/.vs/slnx.sqlite and b/.vs/slnx.sqlite differ diff --git a/Zurnal/Domain/UseCase/UseCasePresence.cs b/Zurnal/Domain/UseCase/UseCasePresence.cs index f6ddb9e..2c84b9e 100644 --- a/Zurnal/Domain/UseCase/UseCasePresence.cs +++ b/Zurnal/Domain/UseCase/UseCasePresence.cs @@ -1,56 +1,38 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace Zurnal.Domain.UseCase +namespace Zurnal.Presence { internal class UseCasePresence { - private Dictionary> attendanceRecords; + private List attendanceRecords; - public UseCasePresence() + public UseCasePresence(List attendanceRecords) { - attendanceRecords = new Dictionary>(); + this.attendanceRecords = attendanceRecords; } - public void MarkAttendance(string group, DateTime date) + public List GetAttendanceByGroup(string groupNumber) { - if (!attendanceRecords.ContainsKey(group)) - { - attendanceRecords[group] = new List(); - } - attendanceRecords[group].Add(date); + return attendanceRecords.Where(record => record.GroupNumber == groupNumber).ToList(); } - public List GetAttendanceByGroup(string group) + public List GetAttendanceByGroupAndDate(string groupNumber, DateTime date) { - if (attendanceRecords.ContainsKey(group)) - { - return attendanceRecords[group]; - } - return new List(); + return attendanceRecords.Where(record => record.GroupNumber == groupNumber && record.Date.Date == date.Date).ToList(); } - public List GetAttendanceByGroupAndDate(string group, DateTime date) + public void MarkUserAsAbsent(string groupNumber, int firstLesson, int lastLesson, DateTime date) { - if (attendanceRecords.ContainsKey(group)) + foreach (var lesson in Enumerable.Range(firstLesson, lastLesson - firstLesson + 1)) { - return attendanceRecords[group].Where(d => d.Date == date.Date).ToList(); - } - return new List(); - } - - public void MarkUserAsAbsent(string group, DateTime startDate, DateTime endDate) - { - if (attendanceRecords.ContainsKey(group)) - { - for (DateTime date = startDate; date <= endDate; date = date.AddDays(1)) + var record = attendanceRecords.FirstOrDefault(r => r.GroupNumber == groupNumber && r.LessonNumber == lesson && r.Date.Date == date.Date); + if (record != null) { - attendanceRecords[group].Remove(date); + record.IsPresent = false; } } } } -} +} \ No newline at end of file