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
801 B
21 lines
801 B
using ErsatzTV.Core.Domain.Scheduling; |
|
using ErsatzTV.Infrastructure.Data; |
|
using Microsoft.EntityFrameworkCore; |
|
|
|
namespace ErsatzTV.Application.Scheduling; |
|
|
|
public class GetDecosByDecoGroupIdHandler(IDbContextFactory<TvContext> dbContextFactory) |
|
: IRequestHandler<GetDecosByDecoGroupId, List<DecoViewModel>> |
|
{ |
|
public async Task<List<DecoViewModel>> Handle(GetDecosByDecoGroupId request, CancellationToken cancellationToken) |
|
{ |
|
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken); |
|
|
|
List<Deco> decos = await dbContext.Decos |
|
.Filter(b => b.DecoGroupId == request.DecoGroupId) |
|
.AsNoTracking() |
|
.ToListAsync(cancellationToken); |
|
|
|
return decos.Map(Mapper.ProjectToViewModel).ToList(); |
|
} |
|
}
|
|
|