* fix validation in new form layout * pin mediatr to last oss version * update dependencies * cleanup code in core * cleanup code in ffmpeg * cleanup code in infra * cleanup code in scanner * cleanup code in application * cleanup main code * cleanup test code * solution-wide code cleanup
25 lines
969 B
C#
25 lines
969 B
C#
using ErsatzTV.Infrastructure.Data;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace ErsatzTV.Application.Scheduling;
|
|
|
|
public class GetTemplateItemsHandler(IDbContextFactory<TvContext> dbContextFactory)
|
|
: IRequestHandler<GetTemplateItems, List<TemplateItemViewModel>>
|
|
{
|
|
public async Task<List<TemplateItemViewModel>> Handle(GetTemplateItems request, CancellationToken cancellationToken)
|
|
{
|
|
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
|
|
|
// drop items that are invalid
|
|
return await dbContext.TemplateItems
|
|
.AsNoTracking()
|
|
.Filter(i => i.TemplateId == request.TemplateId)
|
|
.Include(i => i.Block)
|
|
.ToListAsync(cancellationToken)
|
|
.Map(items => items
|
|
.Map(Mapper.ProjectToViewModel)
|
|
.Filter(i => i.StartTime < i.EndTime || i.EndTime.TimeOfDay == TimeSpan.Zero)
|
|
.ToList());
|
|
}
|
|
}
|