* 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
876 B
C#
23 lines
876 B
C#
using ErsatzTV.Core.Domain.Scheduling;
|
|
using ErsatzTV.Infrastructure.Data;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace ErsatzTV.Application.Scheduling;
|
|
|
|
public class GetBlocksByBlockGroupIdHandler(IDbContextFactory<TvContext> dbContextFactory)
|
|
: IRequestHandler<GetBlocksByBlockGroupId, List<BlockViewModel>>
|
|
{
|
|
public async Task<List<BlockViewModel>> Handle(GetBlocksByBlockGroupId request, CancellationToken cancellationToken)
|
|
{
|
|
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
|
|
|
List<Block> blocks = await dbContext.Blocks
|
|
.Filter(b => b.BlockGroupId == request.BlockGroupId)
|
|
.AsNoTracking()
|
|
.Include(b => b.BlockGroup)
|
|
.ToListAsync(cancellationToken);
|
|
|
|
return blocks.OrderBy(b => b.Name).Map(Mapper.ProjectToViewModel).ToList();
|
|
}
|
|
}
|