Пример #1
0
        public async Task <RecommendationsList> GetRecommendationsAsync(int statusId, CancellationToken cancellationToken = default)
        {
            try
            {
                _connectivityService.CheckConnection();
                cancellationToken.ThrowIfCancellationRequested();

                var recommendationsList = await _platformClient.Endpoints.GetRecommendationsAsync(statusId, cancellationToken).ConfigureAwait(false);

                cancellationToken.ThrowIfCancellationRequested();
                await _recommendationsContainer.SetAsync(recommendationsList).ConfigureAwait(false);

                return(recommendationsList);
            }
            catch (Exception ex)
            {
                if (_serviceErrorHandler.TryHandle(ex, out var generatedException, cancellationToken))
                {
                    if (!(ex is OperationCanceledException))
                    {
                        _logger.LogError(ex, "Failed to load user recommendations.");
                    }
                    generatedException.Rethrow();
                }

                throw;
            }
        }
Пример #2
0
        public async Task <Client.Services.Platform.Models.UserState> GetUserStateAsync(CancellationToken cancellationToken = default)
        {
            try
            {
                cancellationToken.ThrowIfCancellationRequested();
                var result = await GetUserStateInternalAsync(cancellationToken).ConfigureAwait(false);

                return(result);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Failed to load user information.");
                if (_serviceErrorHandler.TryHandle(ex, out var generatedException))
                {
                    generatedException.Rethrow();
                }

                throw;
            }
        }
Пример #3
0
        public async Task <Metadata> UpdateMetadataAsync(CancellationToken cancellationToken = default)
        {
            try
            {
                cancellationToken.ThrowIfCancellationRequested();

                var result = await LoadDataInternalAsync(cancellationToken).ConfigureAwait(false);

                return(result);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Failed to load metadata information.");
                if (_serviceErrorHandler.TryHandle(ex, out var generatedException))
                {
                    generatedException.Rethrow();
                }

                throw;
            }
        }