|
|
|
@ -76,13 +76,13 @@ namespace Contextlib
|
|
|
|
|
|
|
|
|
|
public async Task<PaginationResult<Commentary>> GetAllCommentary()
|
|
|
|
|
{
|
|
|
|
|
var comments = await _context.comments.Include(c => c.User).ToListAsync();
|
|
|
|
|
var comments = await _context.comments.Include(c => c.User).Include(c=>c.User.Images).ToListAsync();
|
|
|
|
|
return new PaginationResult<Commentary>(comments.Count, 0, comments.Count, comments);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<Commentary> GetCommentaryById(int id)
|
|
|
|
|
{
|
|
|
|
|
var comment = await _context.comments.Include(c => c.User).Where(x => x.Id == id).FirstOrDefaultAsync();
|
|
|
|
|
var comment = await _context.comments.Include(c => c.User).Include(c => c.User.Images).Where(x => x.Id == id).FirstOrDefaultAsync();
|
|
|
|
|
if(comment == null)
|
|
|
|
|
{
|
|
|
|
|
throw new KeyNotFoundException($"No comments found with the given ID: {id}.");
|
|
|
|
@ -92,7 +92,7 @@ namespace Contextlib
|
|
|
|
|
|
|
|
|
|
public async Task<PaginationResult<Commentary>> GetCommentaryByQuote(int quoteId, int index, int pageSize)
|
|
|
|
|
{
|
|
|
|
|
var comments = await _context.comments.Include(c => c.User).Where(x => x.IdQuote == quoteId).ToListAsync();
|
|
|
|
|
var comments = await _context.comments.Include(c => c.User).Include(c => c.User.Images).Where(x => x.IdQuote == quoteId).ToListAsync();
|
|
|
|
|
if (!comments.Any())
|
|
|
|
|
{
|
|
|
|
|
throw new KeyNotFoundException($"No comments found for the quote ID: {quoteId}.");
|
|
|
|
|