fix: db model fixes and quote mapping

This commit is contained in:
2025-07-15 16:38:37 +02:00
parent a355c668bd
commit e2eea51a08
9 changed files with 98 additions and 31 deletions

View File

@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using QuotifyBE.Data;
using QuotifyBE.Entities;
using QuotifyBE.Mapping;
using System.Security.Claims;
using Microsoft.EntityFrameworkCore;
@@ -40,7 +41,7 @@ public class QuotesController : ControllerBase
.Include(q => q.QuoteCategories!)
.ThenInclude(qc => qc.Category)
.Include(q => q.User)
.Include(q => q.ImageId)
.Include(q => q.Image)
.FirstOrDefaultAsync(q => q.Id == id);
if (quote == null)
@@ -48,7 +49,7 @@ public class QuotesController : ControllerBase
// TODO: Consider turning the quote into a DTO
return Ok(quote);
return Ok(quote.ToQuoteShortDTO(_db));
}
// POST /api/v1/quotes/new
@@ -135,7 +136,7 @@ public class QuotesController : ControllerBase
image = await _db.Images.FirstOrDefaultAsync(i => i.Id == quote.ImageId);
}
var dto = new RandomQuote
var dto = new QuoteShortDTO
{
Text = quote.Text,
Author = quote.Author,