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.
29 lines
1.1 KiB
29 lines
1.1 KiB
using ErsatzTV.Infrastructure.Data; |
|
using Microsoft.EntityFrameworkCore; |
|
|
|
namespace ErsatzTV.Application.ProgramSchedules; |
|
|
|
public class GetAllProgramSchedulesHandler : IRequestHandler<GetAllProgramSchedules, List<ProgramScheduleViewModel>> |
|
{ |
|
private readonly IDbContextFactory<TvContext> _dbContextFactory; |
|
|
|
public GetAllProgramSchedulesHandler(IDbContextFactory<TvContext> dbContextFactory) => |
|
_dbContextFactory = dbContextFactory; |
|
|
|
public async Task<List<ProgramScheduleViewModel>> Handle( |
|
GetAllProgramSchedules request, |
|
CancellationToken cancellationToken) |
|
{ |
|
await using TvContext dbContext = _dbContextFactory.CreateDbContext(); |
|
return await dbContext.ProgramSchedules |
|
.Map( |
|
ps => new ProgramScheduleViewModel( |
|
ps.Id, |
|
ps.Name, |
|
ps.KeepMultiPartEpisodesTogether, |
|
ps.TreatCollectionsAsShows, |
|
ps.ShuffleScheduleItems, |
|
ps.RandomStartPoint)) |
|
.ToListAsync(cancellationToken); |
|
} |
|
}
|
|
|