Files
ersatztv/ErsatzTV.Application/Scheduling/Queries/GetDecosByDecoGroupIdHandler.cs
T
Jason DoveandGitHub 788a1ecdc4 add deco break content (#2446)
* add initial models

* migrations

* edit break content mode

* add and remove break content from ui

* use autocompletes in deco editor

* save break content to db

* allow break content playlists

* refactor default filler build

* fix slow startup

* start to implement adding break content

* use clone; try to fix block breaks

* fix updating history

* use consistent removebefore values

* cleanup logging

* only allow playlist break content

* update changelog
2025-09-19 18:48:51 +00:00

28 lines
1.1 KiB
C#

using ErsatzTV.Core.Domain.Scheduling;
using ErsatzTV.Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.Scheduling;
public class GetDecosByDecoGroupIdHandler(IDbContextFactory<TvContext> dbContextFactory)
: IRequestHandler<GetDecosByDecoGroupId, List<DecoViewModel>>
{
public async Task<List<DecoViewModel>> Handle(GetDecosByDecoGroupId request, CancellationToken cancellationToken)
{
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
List<Deco> decos = await dbContext.Decos
.AsNoTracking()
.Include(d => d.BreakContent)
.Include(d => d.DecoGroup)
.Include(d => d.DecoWatermarks)
.ThenInclude(d => d.Watermark)
.Include(d => d.DecoGraphicsElements)
.ThenInclude(d => d.GraphicsElement)
.Filter(b => b.DecoGroupId == request.DecoGroupId)
.ToListAsync(cancellationToken);
return decos.OrderBy(d => d.Name).Map(Mapper.ProjectToViewModel).ToList();
}
}