コード例 #1
0
    public async Task <Either <BaseError, Unit> > Handle(
        AddEpisodeToCollection request,
        CancellationToken cancellationToken)
    {
        await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);

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

        return(await LanguageExtensions.Apply(
                   validation,
                   parameters => ApplyAddTelevisionEpisodeRequest(dbContext, parameters)));
    }
コード例 #2
0
        private async Task <Unit> ApplyAddTelevisionEpisodeRequest(AddEpisodeToCollection request)
        {
            if (await _mediaCollectionRepository.AddMediaItem(request.CollectionId, request.EpisodeId))
            {
                // rebuild all playouts that use this collection
                foreach (int playoutId in await _mediaCollectionRepository
                         .PlayoutIdsUsingCollection(request.CollectionId))
                {
                    await _channel.WriteAsync(new BuildPlayout(playoutId, true));
                }
            }

            return(Unit.Default);
        }
コード例 #3
0
 private static async Task <Validation <BaseError, Parameters> > Validate(
     TvContext dbContext,
     AddEpisodeToCollection request) =>
 (await CollectionMustExist(dbContext, request), await ValidateEpisode(dbContext, request))
コード例 #4
0
 private async Task <Validation <BaseError, Unit> > Validate(AddEpisodeToCollection request) =>
 (await CollectionMustExist(request), await ValidateEpisode(request))
コード例 #5
0
 public Task <Either <BaseError, Unit> > Handle(
     AddEpisodeToCollection request,
     CancellationToken cancellationToken) =>
 Validate(request)
 .MapT(_ => ApplyAddTelevisionEpisodeRequest(request))
 .Bind(v => v.ToEitherAsync());