//[NoCache]
        //[ProducesResponseType(typeof(List<Story>), 200)]
        // [ProducesResponseType(typeof(ApiResponse), 400)]
        public async Task <ActionResult> NewStories(string searchTerm)
        {
            try
            {
                var newStories = await _hackerNewsService.GetNewStoriesAsync(searchTerm);

                return(Ok(newStories));
            }
            catch (Exception) //ex)
            {
                // _logger.LogError(ex.Message);
                return(BadRequest(new ApiResponse {
                    Status = false
                }));
            }
        }
예제 #2
0
        public async Task <ActionResult> NewStories()
        {
            try
            {
                var newStories = await _hackerNewsService.GetNewStoriesAsync();

                return(Ok(newStories));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(BadRequest(new ApiResponse {
                    Status = false, ErrorMessage = $"Could not load hacker news feed"
                }));
            }
        }
예제 #3
0
        public async Task <ActionResult> NewStories(string searchTerm)
        {
            Console.WriteLine("new stories", searchTerm);
            try
            {
                var newStories = await _hackerNewsService.GetNewStoriesAsync(searchTerm);

                return(Ok(newStories));
            }
            catch (Exception) //ex)
            {
                // _logger.LogError(ex.Message);
                return(BadRequest(new ApiResponse {
                    Status = false, ErrorMessage = $"Could not load hacker news feed"
                }));
            }
        }