using Microsoft.EntityFrameworkCore;
using SportsDivision.Domain.Entities;
using SportsDivision.Domain.Interfaces;
using SportsDivision.Infrastructure.Data;

namespace SportsDivision.Infrastructure.Repositories;

public class HeatRepository : Repository<Heat>, IHeatRepository
{
    public HeatRepository(ApplicationDbContext context) : base(context) { }

    public async Task<Heat?> GetWithLanesAsync(int heatId) =>
        await _dbSet
            .Include(h => h.HeatLanes)
                .ThenInclude(l => l.EventRegistration)
                    .ThenInclude(r => r.Student!)
                        .ThenInclude(s => s.School)
            .FirstOrDefaultAsync(h => h.HeatId == heatId);
}
