48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
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<LessonPresence>();
|
|
|
|
foreach (var user in users)
|
|
{
|
|
// Создаем список посещаемости, по умолчанию все отмечены как присутствующие
|
|
var lessons = new List<bool> { true, true, true }; // Пример, 3 занятия
|
|
presenceList.Add(new LessonPresence(user.UserId, date, groupNumber, lessons));
|
|
}
|
|
|
|
_presenceRepository.SavePresence(presenceList);
|
|
}
|
|
|
|
public List<LessonPresence> GetPresenceByGroup(int groupNumber)
|
|
{
|
|
return _presenceRepository.GetPresenceByGroup(groupNumber);
|
|
}
|
|
|
|
public List<LessonPresence> 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);
|
|
}
|
|
}
|
|
}
|