chore: cleanup

This commit is contained in:
limited_dev 2023-02-03 11:33:56 +01:00
parent 0e725b065a
commit f5ac34e639
17 changed files with 67 additions and 3 deletions

View file

@ -22,8 +22,23 @@ public static class CommentsRepository
public static async Task<CommentData> getCommentByIdAsync(int postId)
{
await using var db = new AppDBContext();
return await db.Comments.FirstOrDefaultAsync(comment => comment.PostID == postId);
return await db.Comments
.Where(comment => comment.CommentID == postId)
.Include(comment => comment.Image)
.Include(comment => comment.Post)
.FirstOrDefaultAsync();
}
/*public static async Task<PostData> getPostByIdAsync(int postId)
{
await using var db = new AppDBContext();
return await db.Posts
.Where(post => post.PostID == postId)
.Include(post => post.Image)
.Include(post => post.Comments)
.FirstOrDefaultAsync();
//return await db.Posts.FirstOrDefaultAsync(post => post.PostID == postId);
}*/
public static async Task<int> createCommentAsync(CommentData commentData)
{

View file

@ -17,6 +17,7 @@ public static class PostsRepository
.Where(post => post.Board.Equals(board))
.Include(post => post.Image)
.Include(post => post.Comments)
.Include(post => post.User)
.ToListAsync();
}
@ -27,6 +28,7 @@ public static class PostsRepository
.Where(post => post.PostID == postId)
.Include(post => post.Image)
.Include(post => post.Comments)
.Include(post => post.User)
.FirstOrDefaultAsync();
//return await db.Posts.FirstOrDefaultAsync(post => post.PostID == postId);
}