Files
ersatztv/ErsatzTV.Application/Scheduling/Queries/GetAllTemplateGroupsHandler.cs
T
Jason DoveandGitHub 62e140ec98 block scheduling ui cleanup (#2316)
* 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
2025-08-14 01:37:21 +00:00

24 lines
868 B
C#

using ErsatzTV.Core.Domain.Scheduling;
using ErsatzTV.Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.Scheduling;
public class GetAllTemplateGroupsHandler(IDbContextFactory<TvContext> dbContextFactory)
: IRequestHandler<GetAllTemplateGroups, List<TemplateGroupViewModel>>
{
public async Task<List<TemplateGroupViewModel>> Handle(
GetAllTemplateGroups request,
CancellationToken cancellationToken)
{
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
List<TemplateGroup> templateGroups = await dbContext.TemplateGroups
.AsNoTracking()
.Include(g => g.Templates)
.ToListAsync(cancellationToken);
return templateGroups.OrderBy(tg => tg.Name).Map(Mapper.ProjectToViewModel).ToList();
}
}