chore: cleanup
This commit is contained in:
parent
0e725b065a
commit
f5ac34e639
17 changed files with 67 additions and 3 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue