Files
ersatztv/ErsatzTV.Application/Scheduling/Queries/GetDecosByDecoGroupIdHandler.cs
T
Jason DoveandGitHub 908125f8a9 allow selecting multiple watermarks on decos (#2287)
* load fonts on demand

* add new table

* populate new table

* edit and use multiple watermarks in deco

* remove old field

* update changelog
2025-08-09 17:00:12 +00:00

24 lines
888 B
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.DecoWatermarks)
.ThenInclude(d => d.Watermark)
.Filter(b => b.DecoGroupId == request.DecoGroupId)
.ToListAsync(cancellationToken);
return decos.Map(Mapper.ProjectToViewModel).ToList();
}
}