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.
23 lines
839 B
23 lines
839 B
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> blockGroups = await dbContext.TemplateGroups |
|
.AsNoTracking() |
|
.Include(g => g.Templates) |
|
.ToListAsync(cancellationToken); |
|
|
|
return blockGroups.Map(Mapper.ProjectToViewModel).ToList(); |
|
} |
|
}
|
|
|