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
821 B
21 lines
821 B
using ErsatzTV.Infrastructure.Data; |
|
using Microsoft.EntityFrameworkCore; |
|
|
|
namespace ErsatzTV.Application.Scheduling; |
|
|
|
public class GetTemplatesByTemplateGroupIdHandler(IDbContextFactory<TvContext> dbContextFactory) |
|
: IRequestHandler<GetTemplatesByTemplateGroupId, List<TemplateViewModel>> |
|
{ |
|
public async Task<List<TemplateViewModel>> Handle( |
|
GetTemplatesByTemplateGroupId request, |
|
CancellationToken cancellationToken) |
|
{ |
|
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken); |
|
|
|
return await dbContext.Templates |
|
.AsNoTracking() |
|
.Filter(i => i.TemplateGroupId == request.TemplateGroupId) |
|
.ToListAsync(cancellationToken) |
|
.Map(items => items.Map(Mapper.ProjectToViewModel).ToList()); |
|
} |
|
}
|
|
|