Files
ersatztv/ErsatzTV.Application/Scheduling/Queries/GetDecoTemplateTreeHandler.cs
Jason Dove 5d081ceeff fix editorconfig and run code cleanup (#2324)
* fix formatting rules

* reformat ersatztv

* reformat ersatztv.application

* reformat ersatztv.core

* refactor ersatztv.core.tests

* reformat ersatztv.ffmpeg

* reformat ersatztv.ffmpeg.tests

* reformat ersatztv.infrastructure

* cleanup infra mysql

* cleanup infra sqlite

* cleanup infra tests

* cleanup ersatztv.scanner

* cleanup ersatztv.scanner.tests

* sln cleanup

* update dependencies
2025-08-16 14:44:48 +00:00

25 lines
852 B
C#

using ErsatzTV.Application.Tree;
using ErsatzTV.Core.Domain.Scheduling;
using ErsatzTV.Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.Scheduling;
public class GetDecoTemplateTreeHandler(IDbContextFactory<TvContext> dbContextFactory)
: IRequestHandler<GetDecoTemplateTree, TreeViewModel>
{
public async Task<TreeViewModel> Handle(
GetDecoTemplateTree request,
CancellationToken cancellationToken)
{
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
List<DecoTemplateGroup> decoTemplateGroups = await dbContext.DecoTemplateGroups
.AsNoTracking()
.Include(g => g.DecoTemplates)
.ToListAsync(cancellationToken);
return Mapper.ProjectToViewModel(decoTemplateGroups);
}
}