45 lines
1.6 KiB
C#
45 lines
1.6 KiB
C#
// C:\Users\class_Student\source\repos\slarny4\Demo1\Domain\UseCase\PresenceUseCase.cs
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using Demo.Data.LocalData.Entity;
|
|
using Demo.Data.Repository;
|
|
|
|
namespace Demo.Domain.UseCase
|
|
{
|
|
public class PresenceUseCase
|
|
{
|
|
private readonly IPresenceRepository _presenceRepository;
|
|
private readonly IGroupRepository _groupRepository;
|
|
private readonly IUserRepository _userRepository;
|
|
|
|
public PresenceUseCase(IPresenceRepository presenceRepository, IGroupRepository groupRepository, IUserRepository userRepository)
|
|
{
|
|
_presenceRepository = presenceRepository;
|
|
_groupRepository = groupRepository;
|
|
_userRepository = userRepository;
|
|
}
|
|
|
|
public IEnumerable<LocalPresence> GetPresencesByGroupAndDate(int groupId, DateTime date)
|
|
{
|
|
return _presenceRepository.GetPresencesByGroupAndDate(groupId, date);
|
|
}
|
|
|
|
public void MarkUserAbsent(Guid userId, int lessonNumber, DateTime date)
|
|
{
|
|
var presence = _presenceRepository.GetAllPresences();
|
|
foreach (var p in presence)
|
|
{
|
|
if (p.UserId == userId && p.ClassDate.Date == date.Date && p.LessonNumber == lessonNumber)
|
|
{
|
|
p.WasPresent = false;
|
|
_presenceRepository.UpdatePresence(p);
|
|
}
|
|
}
|
|
}
|
|
|
|
public IEnumerable<LocalPresence> GetAllPresences()
|
|
{
|
|
return _presenceRepository.GetAllPresences();
|
|
}
|
|
}
|
|
} |