38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Zurnal.Presence
|
|
{
|
|
internal class UseCasePresence
|
|
{
|
|
private List<AttendanceRecord> attendanceRecords;
|
|
|
|
public UseCasePresence(List<AttendanceRecord> attendanceRecords)
|
|
{
|
|
this.attendanceRecords = attendanceRecords;
|
|
}
|
|
|
|
public List<AttendanceRecord> GetAttendanceByGroup(string groupNumber)
|
|
{
|
|
return attendanceRecords.Where(record => record.GroupNumber == groupNumber).ToList();
|
|
}
|
|
|
|
public List<AttendanceRecord> 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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |