public async Task <IActionResult> GetLatest() { await Db.Connection.OpenAsync(); var query = new QuotesQuery(Db); var result = await query.LatestPostsAsync(); return(new OkObjectResult(result)); }
public async Task <IActionResult> GetRandomQuote([FromQuery] QuotesQuery query) { // KEEP IT LAST because it will mess up the pagination otherwise if (query.Amount != 1) { return(await GetRandomQuotes(query)); } Quote quote = await _quotesService.GetRandomQuote(); if (quote == null) { return(NotFound()); } return(Ok(_mapper.Map <QuoteReadDTO>(quote))); }
public IEnumerable <Quote> Handle(QuotesQuery query) { return(_entities.Query <Quote>().AsEnumerable <Quote>()); }
// Private for seperation of concers private async Task <IActionResult> GetRandomQuotes([FromBody] QuotesQuery query) { return(Ok(_mapper.Map <List <QuoteReadDTO> > (await _quotesService.GetRandomQuotes(query.Amount)))); }