Raspisanie/Zurnal/Presence/UseCaseGeneratePresence.cs

50 lines
1.6 KiB
C#
Raw Normal View History

2024-10-21 11:56:16 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Zurnal.Presence
{
internal class UseCaseGeneratePresence
{
2024-10-23 08:14:10 +00:00
internal class AttendanceRecord
{
public int LessonNumber { get; set; }
2024-10-23 08:27:57 +00:00
public required string GroupNumber { get; set; }
2024-10-23 08:14:10 +00:00
public DateTime Date { get; set; }
public bool IsPresent { get; set; }
}
2024-10-21 11:56:16 +00:00
public List<AttendanceRecord> GenerateDailyAttendance(int firstLesson, int lastLesson, string groupNumber, DateTime currentDate)
{
List<AttendanceRecord> attendanceRecords = new List<AttendanceRecord>();
for (int lesson = firstLesson; lesson <= lastLesson; lesson++)
{
attendanceRecords.Add(new AttendanceRecord
{
LessonNumber = lesson,
GroupNumber = groupNumber,
Date = currentDate,
IsPresent = true
});
}
return attendanceRecords;
}
public List<AttendanceRecord> GenerateWeeklyAttendance(int firstLesson, int lastLesson, string groupNumber, DateTime startDate)
{
List<AttendanceRecord> weeklyAttendanceRecords = new List<AttendanceRecord>();
for (int day = 0; day < 7; day++)
{
DateTime currentDate = startDate.AddDays(day);
weeklyAttendanceRecords.AddRange(GenerateDailyAttendance(firstLesson, lastLesson, groupNumber, currentDate));
}
return weeklyAttendanceRecords;
}
}
}