One
This commit is contained in:
parent
60195b921a
commit
fdfa48d9b9
BIN
.vs/slnx.sqlite
BIN
.vs/slnx.sqlite
Binary file not shown.
@ -1,54 +1,36 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Zurnal.Domain.UseCase
|
namespace Zurnal.Presence
|
||||||
{
|
{
|
||||||
internal class UseCasePresence
|
internal class UseCasePresence
|
||||||
{
|
{
|
||||||
private Dictionary<string, List<DateTime>> attendanceRecords;
|
private List<AttendanceRecord> attendanceRecords;
|
||||||
|
|
||||||
public UseCasePresence()
|
public UseCasePresence(List<AttendanceRecord> attendanceRecords)
|
||||||
{
|
{
|
||||||
attendanceRecords = new Dictionary<string, List<DateTime>>();
|
this.attendanceRecords = attendanceRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MarkAttendance(string group, DateTime date)
|
public List<AttendanceRecord> GetAttendanceByGroup(string groupNumber)
|
||||||
{
|
{
|
||||||
if (!attendanceRecords.ContainsKey(group))
|
return attendanceRecords.Where(record => record.GroupNumber == groupNumber).ToList();
|
||||||
{
|
|
||||||
attendanceRecords[group] = new List<DateTime>();
|
|
||||||
}
|
|
||||||
attendanceRecords[group].Add(date);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DateTime> GetAttendanceByGroup(string group)
|
public List<AttendanceRecord> GetAttendanceByGroupAndDate(string groupNumber, DateTime date)
|
||||||
{
|
{
|
||||||
if (attendanceRecords.ContainsKey(group))
|
return attendanceRecords.Where(record => record.GroupNumber == groupNumber && record.Date.Date == date.Date).ToList();
|
||||||
{
|
|
||||||
return attendanceRecords[group];
|
|
||||||
}
|
|
||||||
return new List<DateTime>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DateTime> 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();
|
var record = attendanceRecords.FirstOrDefault(r => r.GroupNumber == groupNumber && r.LessonNumber == lesson && r.Date.Date == date.Date);
|
||||||
}
|
if (record != null)
|
||||||
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);
|
record.IsPresent = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user