From 4b7b731679b075fa230a9d6038f6cd65646ff5ae Mon Sep 17 00:00:00 2001 From: eee4 <41441600+eee4@users.noreply.github.com> Date: Wed, 16 Jul 2025 12:20:47 +0200 Subject: [PATCH] fix: return id for random quote as well --- Controllers/QuoteController.cs | 39 +++++++++++++++++----------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/Controllers/QuoteController.cs b/Controllers/QuoteController.cs index 63187ca..0665bf9 100644 --- a/Controllers/QuoteController.cs +++ b/Controllers/QuoteController.cs @@ -38,25 +38,25 @@ public class QuotesController : ControllerBase [ProducesResponseType(typeof(List), 200)] [ProducesResponseType(typeof(ErrorDTO), 404)] public async Task GetQuotePage(int page_no) - { - var totalQuotes = await _db.Quotes.CountAsync(); - const int PageSize = 10; - - if (page_no <= 0) - { - return NotFound(new ErrorDTO { Status = "error", error_msg = "Numer strony musi być większy niż 0." }); - } - var quotes = await _db.Quotes.Include(q => q.QuoteCategories).ThenInclude(qc => qc.Category).Include(q => q.User).Include(q => q.Image).OrderBy(q => q.Id).Skip((page_no-1)*PageSize).Take(PageSize).ToListAsync(); - - - - if (quotes == null || totalQuotes == 0) - { - return NotFound(new ErrorDTO { Status = "error", error_msg = "Brak cytatów na tej stronie." }); - } - var result = quotes.Select(q => q.ToQuoteShortDTO(_db)).ToList(); - - //return NotFound(new { status = "error", error_msg = "Not implemented" }); + { + var totalQuotes = await _db.Quotes.CountAsync(); + const int PageSize = 10; + + if (page_no <= 0) + { + return NotFound(new ErrorDTO { Status = "error", error_msg = "Numer strony musi być większy niż 0." }); + } + var quotes = await _db.Quotes.Include(q => q.QuoteCategories).ThenInclude(qc => qc.Category).Include(q => q.User).Include(q => q.Image).OrderBy(q => q.Id).Skip((page_no-1)*PageSize).Take(PageSize).ToListAsync(); + + + + if (quotes == null || totalQuotes == 0) + { + return NotFound(new ErrorDTO { Status = "error", error_msg = "Brak cytatów na tej stronie." }); + } + var result = quotes.Select(q => q.ToQuoteShortDTO(_db)).ToList(); + + //return NotFound(new { status = "error", error_msg = "Not implemented" }); return Ok(result); @@ -194,6 +194,7 @@ public class QuotesController : ControllerBase var dto = new QuoteShortDTO { + Id = quote.Id, Text = quote.Text, Author = quote.Author, ImageUrl = image?.Url,