Files
ersatztv/ErsatzTV.Application/Scheduling/Queries/GetPlayoutTemplatesHandler.cs
T
Jason DoveandGitHub dcbe4837bf first pass at block scheduling (#1548)
* add blocks, block groups

* basic block and block item editing

* add template groups and basic template editing (name)

* add blocks to template calendar

* edit playout templates

* add calendar preview to playout templates

* add basic block playout building

* add mysql migration

* update changelog
2024-01-13 22:01:21 -06:00

25 lines
912 B
C#

using ErsatzTV.Core.Domain.Scheduling;
using ErsatzTV.Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.Scheduling;
public class GetPlayoutTemplatesHandler(IDbContextFactory<TvContext> dbContextFactory)
: IRequestHandler<GetPlayoutTemplates, List<PlayoutTemplateViewModel>>
{
public async Task<List<PlayoutTemplateViewModel>> Handle(
GetPlayoutTemplates request,
CancellationToken cancellationToken)
{
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
List<PlayoutTemplate> playoutTemplates = await dbContext.PlayoutTemplates
.AsNoTracking()
.Filter(t => t.PlayoutId == request.PlayoutId)
.Include(t => t.Template)
.ToListAsync(cancellationToken);
return playoutTemplates.Map(Mapper.ProjectToViewModel).ToList();
}
}