feat: return creation/update time

This commit is contained in:
2025-07-28 14:09:51 +02:00
parent 98dc591dce
commit 8a8aac77da
4 changed files with 43 additions and 5 deletions

View File

@@ -29,4 +29,28 @@ public static class QuoteMapping
Categories = categoryNames
};
}
public static QuoteCompleteDTO ToQuoteCompleteDTO(this Quote quote)
{
List<string> categoryNames = [];
if (quote.QuoteCategories != null)
{
foreach (QuoteCategory quoteCategory in quote.QuoteCategories)
{
categoryNames.Add(quoteCategory.Category!.Name ?? $"Unnamed category {quoteCategory.CategoryId}");
}
}
return new QuoteCompleteDTO
{
Id = quote.Id,
Text = quote.Text,
Author = quote.Author,
ImageUrl = quote.Image?.Url,
Categories = categoryNames,
createDate = quote.CreatedAt,
updateDate = quote.LastUpdatedAt
};
}
}