public async Task <ActionResult> Index() { try { var stories = await hackerNewsSvc.GetBestStories(); return(View(stories)); } catch (Exception) { ViewBag.error = "There was a problem retrieving the stories."; return(View(new List <Story>())); } }
public async Task <IActionResult> GetBestStories([FromQuery] int size = 20) { var stories = await _hackerNewsService.GetBestStories(size); if (stories.IsNullOrEmpty()) { return(NoContent()); } var storiesDto = stories.Select(x => new HackerStoryDto { Title = x.Title, Uri = x.Url, PostedBy = x.By, Time = x.GetTime(), Score = x.Score, CommentCount = x.Descendants }); return(Ok(storiesDto)); }
public async Task <IActionResult> Get() { return(CustomResponse(await _hackerNewsService.GetBestStories())); }
public Task <IEnumerable <Article> > Get() { return(_service.GetBestStories()); }
public async Task <ActionResult <IEnumerable <Story> > > Get() { var stories = await _newsService.GetBestStories(_numberOfStories); return(new ActionResult <IEnumerable <Story> >(stories)); }