From b1a6ab211e1a8dbc1f74a529ba374659ea21e96f Mon Sep 17 00:00:00 2001 From: limited_dev Date: Sun, 12 Feb 2023 14:02:01 +0100 Subject: [PATCH] fix: you can now delete posts from the report page --- ImageBoardServerApp/Data/Repository/CommentsRepository.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ImageBoardServerApp/Data/Repository/CommentsRepository.cs b/ImageBoardServerApp/Data/Repository/CommentsRepository.cs index c86a853..83d3384 100644 --- a/ImageBoardServerApp/Data/Repository/CommentsRepository.cs +++ b/ImageBoardServerApp/Data/Repository/CommentsRepository.cs @@ -26,6 +26,8 @@ public static class CommentsRepository .Where(comment => comment.CommentID == postId) .Include(comment => comment.Image) .Include(comment => comment.Post) + .Include(comment => comment.User) + .Include(comment => comment.Report) .FirstOrDefaultAsync(); } @@ -63,6 +65,8 @@ public static class CommentsRepository { await using var db = new AppDBContext(); CommentData commentToDelete = await getCommentByIdAsync(postId); + if (commentToDelete.Report != null) + db.Remove(commentToDelete.Report); db.Remove(commentToDelete); return await db.SaveChangesAsync() >= 1; }