public async Task <IActionResult> GetLatest()
        {
            await Db.Connection.OpenAsync();

            var query  = new QuotesQuery(Db);
            var result = await query.LatestPostsAsync();

            return(new OkObjectResult(result));
        }
예제 #2
0
        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)));
        }
예제 #3
0
 public IEnumerable <Quote> Handle(QuotesQuery query)
 {
     return(_entities.Query <Quote>().AsEnumerable <Quote>());
 }
예제 #4
0
 // Private for seperation of concers
 private async Task <IActionResult> GetRandomQuotes([FromBody] QuotesQuery query)
 {
     return(Ok(_mapper.Map <List <QuoteReadDTO> >
                   (await _quotesService.GetRandomQuotes(query.Amount))));
 }