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