fix: you can now delete posts from the report page
This commit is contained in:
parent
cb7ca62590
commit
b1a6ab211e
1 changed files with 4 additions and 0 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue