using System; using System.Collections.Generic; using Demo.Data.Repository; using Demo.Domain.Models; namespace Demo.Domain.UseCases { public class PresenceUseCase { private readonly IPresenceRepository _presenceRepository; public PresenceUseCase(IPresenceRepository presenceRepository) // Конструктор { _presenceRepository = presenceRepository; } public void GeneratePresence(int groupNumber, DateTime date) { var users = _presenceRepository.GetUsersByGroup(groupNumber); var presenceList = new List(); foreach (var user in users) { // Создаем список посещаемости, по умолчанию все отмечены как присутствующие var lessons = new List { true, true, true }; // Пример, 3 занятия presenceList.Add(new LessonPresence(user.UserId, date, groupNumber, lessons)); } _presenceRepository.SavePresence(presenceList); } public List GetPresenceByGroup(int groupNumber) { return _presenceRepository.GetPresenceByGroup(groupNumber); } public List GetPresenceByGroupAndDate(int groupNumber, DateTime date) { return _presenceRepository.GetPresenceByGroupAndDate(groupNumber, date); } public void MarkUserAbsent(Guid userId, int groupNumber, int lessonId, DateTime date) { _presenceRepository.MarkUserAbsent(userId, groupNumber, lessonId, date); } } }