64 lines
2.3 KiB
C#
64 lines
2.3 KiB
C#
|
using Demo.Data.LocalData;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace Demo.Domain.Presence
|
|||
|
{
|
|||
|
|
|||
|
public class UseCaseGeneratePresence
|
|||
|
{
|
|||
|
public List<AttendanceRecord> GenerateDailyAttendance(int firstLesson, int lastLesson, string groupNumber, DateTime currentDate)
|
|||
|
{
|
|||
|
List<AttendanceRecord> attendanceRecords = new List<AttendanceRecord>();
|
|||
|
|
|||
|
// Проверка на корректность входных данных
|
|||
|
if (firstLesson < 1 || lastLesson < firstLesson)
|
|||
|
{
|
|||
|
throw new ArgumentException("Неверные номера уроков.");
|
|||
|
}
|
|||
|
|
|||
|
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>();
|
|||
|
|
|||
|
// Проверка на корректность входных данных
|
|||
|
if (firstLesson < 1 || lastLesson < firstLesson)
|
|||
|
{
|
|||
|
throw new ArgumentException("Неверные номера уроков.");
|
|||
|
}
|
|||
|
|
|||
|
for (int day = 0; day < 7; day++)
|
|||
|
{
|
|||
|
DateTime currentDate = startDate.AddDays(day);
|
|||
|
weeklyAttendanceRecords.AddRange(GenerateDailyAttendance(firstLesson, lastLesson, groupNumber, currentDate));
|
|||
|
}
|
|||
|
|
|||
|
return weeklyAttendanceRecords;
|
|||
|
}
|
|||
|
|
|||
|
public class AttendanceRecord
|
|||
|
{
|
|||
|
public int LessonNumber { get; set; }
|
|||
|
public string GroupNumber { get; set; }
|
|||
|
public DateTime Date { get; set; }
|
|||
|
public bool IsPresent { get; set; }
|
|||
|
}
|
|||
|
}
|
|||
|
}
|