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

namespace SportsDivision.Infrastructure.Repositories;

public class EventRepository : Repository<Event>, IEventRepository
{
    public EventRepository(ApplicationDbContext context) : base(context) { }
    public async Task<IEnumerable<Event>> GetByCategoryAsync(EventCategory category) => await _dbSet.Where(e => e.Category == category).OrderBy(e => e.Name).ToListAsync();
    public async Task<Event?> GetWithEventLevelsAsync(int eventId) => await _dbSet.Include(e => e.EventLevels).FirstOrDefaultAsync(e => e.EventId == eventId);
    public async Task<IEnumerable<Event>> GetBySchoolLevelAsync(bool primarySchool, bool secondarySchool) => await _dbSet.Where(e => (primarySchool && e.PrimarySchool) || (secondarySchool && e.SecondarySchool)).OrderBy(e => e.Name).ToListAsync();
}
