2024-11-11 08:31:26 +00:00
|
|
|
|
using Zurnal.RemaDateBase.DateDao;
|
|
|
|
|
using static Zurnal.Presence.UseCaseGeneratePresence;
|
2024-10-21 11:56:16 +00:00
|
|
|
|
|
2024-10-23 08:27:57 +00:00
|
|
|
|
namespace Zurnal.Domain.UseCase
|
2024-10-21 11:56:16 +00:00
|
|
|
|
{
|
|
|
|
|
internal class UseCasePresence
|
|
|
|
|
{
|
2024-11-11 08:31:26 +00:00
|
|
|
|
private List<PresnceDao> attendanceRecords;
|
2024-10-21 11:56:16 +00:00
|
|
|
|
|
2024-11-11 08:31:26 +00:00
|
|
|
|
public UseCasePresence(List<PresnceDao> attendanceRecords)
|
2024-10-21 11:56:16 +00:00
|
|
|
|
{
|
2024-10-21 12:07:01 +00:00
|
|
|
|
this.attendanceRecords = attendanceRecords;
|
2024-10-21 11:56:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-11 08:31:26 +00:00
|
|
|
|
public List<PresnceDao> GetAttendanceByGroup(string groupNumber)
|
2024-10-21 11:56:16 +00:00
|
|
|
|
{
|
2024-11-11 08:31:26 +00:00
|
|
|
|
return attendanceRecords.Where(record => record.userDao.Group.GroupName == groupNumber).ToList();
|
2024-10-21 11:56:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-11 08:31:26 +00:00
|
|
|
|
public List<PresnceDao> GetAttendanceByGroupAndDate(string groupNumber, DateOnly date)
|
2024-10-21 11:56:16 +00:00
|
|
|
|
{
|
2024-11-11 08:31:26 +00:00
|
|
|
|
return attendanceRecords.Where(record => record.userDao.Group.GroupName == groupNumber && record.Date == date).ToList();
|
2024-10-21 11:56:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-11 08:31:26 +00:00
|
|
|
|
public void MarkUserAsAbsent(string groupNumber, int firstLesson, int lastLesson, DateOnly date)
|
2024-10-21 11:56:16 +00:00
|
|
|
|
{
|
2024-10-21 12:07:01 +00:00
|
|
|
|
foreach (var lesson in Enumerable.Range(firstLesson, lastLesson - firstLesson + 1))
|
2024-10-21 11:56:16 +00:00
|
|
|
|
{
|
2024-11-11 08:31:26 +00:00
|
|
|
|
var record = attendanceRecords.FirstOrDefault(r => r.userDao.Group.GroupName == groupNumber && r.LessonNumber == lesson && r.Date == date);
|
2024-10-21 12:07:01 +00:00
|
|
|
|
if (record != null)
|
2024-10-21 11:56:16 +00:00
|
|
|
|
{
|
2024-11-11 08:31:26 +00:00
|
|
|
|
record.IsAttendensy = false;
|
2024-10-21 11:56:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-21 12:07:01 +00:00
|
|
|
|
}
|