HandleImpl(ISynchronizeEmbyLibraryById request, CancellationToken cancellationToken)
    {
        Validation <BaseError, RequestParameters> validation = await Validate(request);

        return(await validation.Match(
                   parameters => Synchronize(parameters, cancellationToken),
                   error => Task.FromResult <Either <BaseError, string> >(error.Join())));
    }
Esempio n. 2
0
    // private async Task SynchronizeAdminUserId(
    //     SynchronizeEmbyAdminUserId request,
    //     CancellationToken cancellationToken)
    // {
    //     using IServiceScope scope = _serviceScopeFactory.CreateScope();
    //     IMediator mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
    //
    //     Either<BaseError, Unit> result = await mediator.Send(request, cancellationToken);
    //     result.BiIter(
    //         _ => _logger.LogInformation(
    //             "Successfully synchronized Emby admin user id for source {MediaSourceId}",
    //             request.EmbyMediaSourceId),
    //         error => _logger.LogWarning(
    //             "Unable to synchronize Emby admin user id for source {MediaSourceId}: {Error}",
    //             request.EmbyMediaSourceId,
    //             error.Value));
    // }

    private async Task SynchronizeEmbyLibrary(
        ISynchronizeEmbyLibraryById request,
        CancellationToken cancellationToken)
    {
        using IServiceScope scope = _serviceScopeFactory.CreateScope();
        IMediator mediator = scope.ServiceProvider.GetRequiredService <IMediator>();

        Either <BaseError, string> result = await mediator.Send(request, cancellationToken);

        result.BiIter(
            name => _logger.LogDebug("Done synchronizing emby library {Name}", name),
            error => _logger.LogWarning(
                "Unable to synchronize emby library {LibraryId}: {Error}",
                request.EmbyLibraryId,
                error.Value));
    }
 private async Task <Validation <BaseError, RequestParameters> > Validate(
     ISynchronizeEmbyLibraryById request) =>
 (await ValidateConnection(request), await EmbyLibraryMustExist(request),