Files
chapter-organizer/WebApp/Services/EventOccurrenceService.cs
T
poprhythm b7e812bb63 Refactor EventOccurrenceService to implement database-backed event occurrence retrieval
This commit updates the EventOccurrenceService to replace mock data with a database-backed implementation for retrieving event occurrences. The GetEventOccurrencesAsync and GetEventOccurrencesForDateRangeAsync methods now utilize Entity Framework to fetch data from the AppDbContext, enhancing the service's functionality and ensuring accurate event management.
2026-01-09 11:54:55 -05:00

34 lines
948 B
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();
}
}