fix: you can now delete posts from the report page

This commit is contained in:
limited_dev 2023-02-12 14:02:01 +01:00
parent cb7ca62590
commit b1a6ab211e

View file

@ -26,6 +26,8 @@ public static class CommentsRepository
.Where(comment => comment.CommentID == postId) .Where(comment => comment.CommentID == postId)
.Include(comment => comment.Image) .Include(comment => comment.Image)
.Include(comment => comment.Post) .Include(comment => comment.Post)
.Include(comment => comment.User)
.Include(comment => comment.Report)
.FirstOrDefaultAsync(); .FirstOrDefaultAsync();
} }
@ -63,6 +65,8 @@ public static class CommentsRepository
{ {
await using var db = new AppDBContext(); await using var db = new AppDBContext();
CommentData commentToDelete = await getCommentByIdAsync(postId); CommentData commentToDelete = await getCommentByIdAsync(postId);
if (commentToDelete.Report != null)
db.Remove(commentToDelete.Report);
db.Remove(commentToDelete); db.Remove(commentToDelete);
return await db.SaveChangesAsync() >= 1; return await db.SaveChangesAsync() >= 1;
} }