using data.DAO; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; namespace data.Repository { public class SQLPresenceRepository : IPresenceRepository { private readonly DatabaseContext _context; public SQLPresenceRepository(DatabaseContext context) { _context = context; } public IEnumerable GetPresence( int groupId, int? subjectId = null, DateTime? date = null, int? studentId = null) { var query = _context.Diaries .Include(p => p.Student) .Include(p => p.StudentGroupSubject) .ThenInclude(p => p.Subject) .Where(p => p.Student.GroupId == groupId); if (subjectId.HasValue) query = query.Where(p => p.StudentGroupSubject.Subject.Id == subjectId.Value); if (date.HasValue) query = query.Where(p => p.Date == DateOnly.FromDateTime(date.Value)); if (studentId.HasValue) query = query.Where(p => p.Student.Id == studentId.Value); return query.ToList(); } } }