private static Task <Validation <BaseError, Playout> > PlayoutMustExist(
     TvContext dbContext,
     BuildPlayout buildPlayout) =>
 dbContext.Playouts
 .Include(p => p.Channel)
 .Include(p => p.Items)
 .Include(p => p.ProgramScheduleAnchors)
 .ThenInclude(a => a.MediaItem)
 .Include(p => p.ProgramSchedule)
 .ThenInclude(ps => ps.Items)
 .ThenInclude(psi => psi.Collection)
 .Include(p => p.ProgramSchedule)
 .ThenInclude(ps => ps.Items)
 .ThenInclude(psi => psi.MediaItem)
 .Include(p => p.ProgramSchedule)
 .ThenInclude(ps => ps.Items)
 .ThenInclude(psi => psi.PreRollFiller)
 .Include(p => p.ProgramSchedule)
 .ThenInclude(ps => ps.Items)
 .ThenInclude(psi => psi.MidRollFiller)
 .Include(p => p.ProgramSchedule)
 .ThenInclude(ps => ps.Items)
 .ThenInclude(psi => psi.PostRollFiller)
 .Include(p => p.ProgramSchedule)
 .ThenInclude(ps => ps.Items)
 .ThenInclude(psi => psi.TailFiller)
 .Include(p => p.ProgramSchedule)
 .ThenInclude(ps => ps.Items)
 .ThenInclude(psi => psi.FallbackFiller)
 .SelectOneAsync(p => p.Id, p => p.Id == buildPlayout.PlayoutId)
 .Map(o => o.ToValidation <BaseError>("Playout does not exist."));
示例#2
0
        private async Task <Either <BaseError, Unit> > ApplyUpdateRequest(BuildPlayout request, Playout playout)
        {
            Playout result = await _playoutBuilder.BuildPlayoutItems(playout, request.Rebuild);

            await _playoutRepository.Update(result);

            return(unit);
        }
    public async Task <Either <BaseError, Unit> > Handle(BuildPlayout request, CancellationToken cancellationToken)
    {
        await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);

        Validation <BaseError, Playout> validation = await Validate(dbContext, request);

        return(await LanguageExtensions.Apply(validation, playout => ApplyUpdateRequest(dbContext, request, playout)));
    }
    private async Task <Unit> ApplyUpdateRequest(TvContext dbContext, BuildPlayout request, Playout playout)
    {
        try
        {
            await _playoutBuilder.Build(playout, request.Mode);

            if (await dbContext.SaveChangesAsync() > 0)
            {
                _ffmpegSegmenterService.PlayoutUpdated(playout.Channel.Number);
            }

            await _ffmpegWorkerChannel.WriteAsync(new ExtractEmbeddedSubtitles(playout.Id));
        }
        catch (Exception ex)
        {
            _client.Notify(ex);
        }

        return(Unit.Default);
    }
示例#5
0
 private async Task <Validation <BaseError, Playout> > PlayoutMustExist(BuildPlayout buildPlayout) =>
 (await _playoutRepository.GetFull(buildPlayout.PlayoutId))
 .ToValidation <BaseError>("Playout does not exist.");
示例#6
0
 private Task <Validation <BaseError, Playout> > Validate(BuildPlayout request) =>
 PlayoutMustExist(request);
示例#7
0
 public Task <Either <BaseError, Unit> > Handle(BuildPlayout request, CancellationToken cancellationToken) =>
 Validate(request)
 .Map(v => v.ToEither <Playout>())
 .BindT(playout => ApplyUpdateRequest(request, playout));
 private static Task <Validation <BaseError, Playout> > Validate(TvContext dbContext, BuildPlayout request) =>
 PlayoutMustExist(dbContext, request);