* update block group editor * update playlist group editor * update template group editor * update deco group editor * update deco template group editor * update deco editor * update logs layout * update changelog
22 lines
756 B
C#
22 lines
756 B
C#
using ErsatzTV.Core.Domain.Scheduling;
|
|
using ErsatzTV.Infrastructure.Data;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace ErsatzTV.Application.Scheduling;
|
|
|
|
public class GetBlockTreeHandler(IDbContextFactory<TvContext> dbContextFactory)
|
|
: IRequestHandler<GetBlockTree, BlockTreeViewModel>
|
|
{
|
|
public async Task<BlockTreeViewModel> Handle(GetBlockTree request, CancellationToken cancellationToken)
|
|
{
|
|
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
|
|
|
List<BlockGroup> blockGroups = await dbContext.BlockGroups
|
|
.AsNoTracking()
|
|
.Include(g => g.Blocks)
|
|
.ToListAsync(cancellationToken);
|
|
|
|
return Mapper.ProjectToViewModel(blockGroups);
|
|
}
|
|
}
|