using ErsatzTV.Infrastructure.Data; using Microsoft.EntityFrameworkCore; namespace ErsatzTV.Application.Playouts; public class GetAllPlayoutsHandler : IRequestHandler> { private readonly IDbContextFactory _dbContextFactory; public GetAllPlayoutsHandler(IDbContextFactory dbContextFactory) => _dbContextFactory = dbContextFactory; public async Task> Handle( GetAllPlayouts request, CancellationToken cancellationToken) { await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken); return await dbContext.Playouts .Filter(p => p.Channel != null && p.ProgramSchedule != null) .Map( p => new PlayoutNameViewModel( p.Id, p.Channel.Name, p.Channel.Number, p.ProgramSchedule.Name, Optional(p.DailyRebuildTime))) .ToListAsync(cancellationToken); } }