using SportsDivision.Domain.Interfaces;
using SportsDivision.Infrastructure.Data;

namespace SportsDivision.Infrastructure.Repositories;

public class UnitOfWork : IUnitOfWork
{
    private readonly ApplicationDbContext _context;
    public UnitOfWork(ApplicationDbContext context)
    {
        _context = context;
        Zones = new ZoneRepository(context);
        Schools = new SchoolRepository(context);
        Students = new StudentRepository(context);
        Events = new EventRepository(context);
        EventLevels = new EventLevelRepository(context);
        Tournaments = new TournamentRepository(context);
        TournamentEventLevels = new TournamentEventLevelRepository(context);
        EventRegistrations = new EventRegistrationRepository(context);
        Scores = new ScoreRepository(context);
        Rounds = new RoundRepository(context);
        Heats = new HeatRepository(context);
        HeatLanes = new HeatLaneRepository(context);
        HighJumpHeights = new HighJumpHeightRepository(context);
        ScoringConstants = new ScoringConstantRepository(context);
        PlacementPointConfigs = new PlacementPointConfigRepository(context);
    }
    public IZoneRepository Zones { get; }
    public ISchoolRepository Schools { get; }
    public IStudentRepository Students { get; }
    public IEventRepository Events { get; }
    public IEventLevelRepository EventLevels { get; }
    public ITournamentRepository Tournaments { get; }
    public ITournamentEventLevelRepository TournamentEventLevels { get; }
    public IEventRegistrationRepository EventRegistrations { get; }
    public IScoreRepository Scores { get; }
    public IRoundRepository Rounds { get; }
    public IHeatRepository Heats { get; }
    public IHeatLaneRepository HeatLanes { get; }
    public IHighJumpHeightRepository HighJumpHeights { get; }
    public IScoringConstantRepository ScoringConstants { get; }
    public IPlacementPointConfigRepository PlacementPointConfigs { get; }
    public async Task<int> SaveChangesAsync() => await _context.SaveChangesAsync();
    public void Dispose() => _context.Dispose();
}
