57 lines
1.6 KiB
C#
57 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Zurnal.Domain.UseCase
|
|
{
|
|
internal class UseCasePresence
|
|
{
|
|
private Dictionary<string, List<DateTime>> attendanceRecords;
|
|
|
|
public UseCasePresence()
|
|
{
|
|
attendanceRecords = new Dictionary<string, List<DateTime>>();
|
|
}
|
|
|
|
public void MarkAttendance(string group, DateTime date)
|
|
{
|
|
if (!attendanceRecords.ContainsKey(group))
|
|
{
|
|
attendanceRecords[group] = new List<DateTime>();
|
|
}
|
|
attendanceRecords[group].Add(date);
|
|
}
|
|
|
|
public List<DateTime> GetAttendanceByGroup(string group)
|
|
{
|
|
if (attendanceRecords.ContainsKey(group))
|
|
{
|
|
return attendanceRecords[group];
|
|
}
|
|
return new List<DateTime>();
|
|
}
|
|
|
|
public List<DateTime> GetAttendanceByGroupAndDate(string group, DateTime date)
|
|
{
|
|
if (attendanceRecords.ContainsKey(group))
|
|
{
|
|
return attendanceRecords[group].Where(d => d.Date == date.Date).ToList();
|
|
}
|
|
return new List<DateTime>();
|
|
}
|
|
|
|
public void MarkUserAsAbsent(string group, DateTime startDate, DateTime endDate)
|
|
{
|
|
if (attendanceRecords.ContainsKey(group))
|
|
{
|
|
for (DateTime date = startDate; date <= endDate; date = date.AddDays(1))
|
|
{
|
|
attendanceRecords[group].Remove(date);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|