presence/domain/Service/PresenceService.cs

47 lines
1.4 KiB
C#
Raw Normal View History

2024-12-05 07:31:49 +00:00
using data.Repository;
using domain.Entity;
using domain.UseCase;
using System;
using System.Collections.Generic;
namespace domain.Service
{
public class PresenceService : IPresenceUseCase
{
private readonly IPresenceRepository _presenceRepository;
public PresenceService(IPresenceRepository presenceRepository)
{
_presenceRepository = presenceRepository;
}
public IEnumerable<PresenceEntity> GetPresence(
int groupId,
int? subjectId = null,
DateTime? date = null,
int? studentId = null)
{
return _presenceRepository.GetPresence(groupId, subjectId, date, studentId).Select(p => new PresenceEntity
{
Id = p.Id,
StudentId = p.Student.Id,
Student = new UserEntity
{
Id = p.Student.Id,
FirstName = p.Student.FirstName,
LastName = p.Student.LastName,
Patronymic = p.Student.Patronymic,
Group = new GroupEntity()
},
SubjectId = p.StudentGroupSubject.Subject.Id,
Subject = new SubjectEntity
{
Id = p.StudentGroupSubject.Subject.Id,
Name = p.StudentGroupSubject.Subject.Name
},
Date = p.Date
});
}
}
}