* 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
23 lines
937 B
C#
23 lines
937 B
C#
using ErsatzTV.Infrastructure.Data;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace ErsatzTV.Application.Scheduling;
|
|
|
|
public class GetDecoTemplatesByDecoTemplateGroupIdHandler(IDbContextFactory<TvContext> dbContextFactory)
|
|
: IRequestHandler<GetDecoTemplatesByDecoTemplateGroupId, List<DecoTemplateViewModel>>
|
|
{
|
|
public async Task<List<DecoTemplateViewModel>> Handle(
|
|
GetDecoTemplatesByDecoTemplateGroupId request,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
|
|
|
return await dbContext.DecoTemplates
|
|
.AsNoTracking()
|
|
.Filter(i => i.DecoTemplateGroupId == request.DecoTemplateGroupId)
|
|
.Include(dt => dt.DecoTemplateGroup)
|
|
.ToListAsync(cancellationToken)
|
|
.Map(items => items.OrderBy(dt => dt.Name).Map(Mapper.ProjectToViewModel).ToList());
|
|
}
|
|
}
|