コード例 #1
0
        public async Task Get_Recommendations_Valid_Id_Return_Ok_With_Results()
        {
            var response = await _walmartOpenApiClient.GetRecommendations(44569327);

            Assert.IsType <RecommendationsResponse>(response);
            Assert.NotEmpty(response.Recommendations);
        }
コード例 #2
0
        public async Task <IActionResult> GetRecommendations(long id)
        {
            _logger.LogWarning("Getting recommendations for product ID {ID}", id);
            var recommendations = await _walmartOpenApiClient.GetRecommendations(id);

            if (recommendations.Errors != null && recommendations.Errors.Any())
            {
                var errorsDto = Mapper.Map <ErrorsDto>(recommendations);
                return(Ok(errorsDto));
            }

            return(Ok(recommendations.Recommendations.Take(10).ToList()));
        }