public IActionResult Get(string boardUrl) { var board = _boardRepository.GetBoardByUrl(boardUrl); if (board == null) { return(NotFound()); } var posts = _fetchPostService.GetPostsForBoard(board); var response = _postResponseMapper.MapDbToResponseList(posts); foreach (var post in response) { post.CommentCount = _commentRepository.GetCommentsCountForPostId(post.ID); } return(Json(response)); }
public IActionResult Get(string username, int recentCommentsCount = 10, int recentPostsCount = 10) { var user = _userRepository.GetUserByName(username); if (user == null) { return(NotFound()); } var lastComments = _commentRepository.GetLastCommentsByUser(user, recentCommentsCount); var lastPosts = _fetchPostService.GetLastPostsByUser(user, recentPostsCount); var userResponse = _userResponseMapper.MapDbToResponse(user); userResponse.RecentComments = _commentResponseMapper.MapDbToResponseList(lastComments); userResponse.RecentPosts = _postResponseMapper.MapDbToResponseList(lastPosts); foreach (var post in userResponse.RecentPosts) { post.CommentCount = _commentRepository.GetCommentsCountForPostId(post.ID); } return(Json(userResponse)); }