mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
756 B
21 lines
756 B
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); |
|
} |
|
}
|
|
|