* sort block tree views * fix naming validation for block scheduling * show deco group name in deco editor * show block group name in block editor * show template group name in template editor * show deco template group name in deco template editor * fix template rename crash * fix block rename crash * fix deco template rename crash
28 lines
1.0 KiB
C#
28 lines
1.0 KiB
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)
|
|
.ThenInclude(t => t.TemplateGroup)
|
|
.Include(t => t.DecoTemplate)
|
|
.ThenInclude(dt => dt.DecoTemplateGroup)
|
|
.ToListAsync(cancellationToken);
|
|
|
|
return playoutTemplates.Map(Mapper.ProjectToViewModel).ToList();
|
|
}
|
|
}
|