ecd6173a44
This commit updates the EventOccurrenceParseResult and EventOccurrenceParserResult classes to consolidate the handling of skipped section headers and event counts into a single set of properties. The previous separate lists and counts for middle school and high school sections have been replaced with a unified approach, improving clarity and maintainability. Additionally, the EventOccurrenceParserService has been modified to reflect these changes, ensuring consistent behavior across the application. This refactor enhances the overall structure of the event parsing logic.
53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
using Core.Entities;
|
|
using Data;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace WebApp.Services;
|
|
|
|
public class EventOccurrenceService : IEventOccurrenceService
|
|
{
|
|
private readonly AppDbContext _context;
|
|
|
|
public EventOccurrenceService(AppDbContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public async Task<IEnumerable<EventOccurrence>> GetEventOccurrencesAsync()
|
|
{
|
|
return await _context.EventOccurrences
|
|
.Include(eo => eo.EventDefinition)
|
|
.OrderBy(eo => eo.StartTime)
|
|
.ToListAsync();
|
|
}
|
|
|
|
public async Task<IEnumerable<EventOccurrence>> GetEventOccurrencesForDateRangeAsync(DateTime start, DateTime end)
|
|
{
|
|
return await _context.EventOccurrences
|
|
.Include(eo => eo.EventDefinition)
|
|
.Where(eo => eo.StartTime.Date >= start.Date && eo.StartTime.Date <= end.Date)
|
|
.OrderBy(eo => eo.StartTime)
|
|
.ToListAsync();
|
|
}
|
|
|
|
public async Task<Dictionary<int, List<Team>>> GetTeamsByEventDefinitionIdsAsync(IEnumerable<int> eventDefinitionIds)
|
|
{
|
|
var ids = eventDefinitionIds.Where(id => id > 0).Distinct().ToList();
|
|
if (!ids.Any())
|
|
{
|
|
return new Dictionary<int, List<Team>>();
|
|
}
|
|
|
|
var teams = await _context.Teams
|
|
.Include(t => t.Students)
|
|
.Include(t => t.Captain)
|
|
.Where(t => ids.Contains(t.Event.Id))
|
|
.ToListAsync();
|
|
|
|
return teams
|
|
.GroupBy(t => t.Event.Id)
|
|
.ToDictionary(g => g.Key, g => g.ToList());
|
|
}
|
|
}
|
|
|