public (IEnumerable <PostViewModel> postViewModels, bool canFetchMore) FetchPosts(bool usePostTypeFilter, Guid courseId, string?postType, DateTime?lastPostCreationTime, int postsToFetch, Guid?userId) { // Get posts for the var posts = !usePostTypeFilter ? _postRepository.FetchPosts(courseId, lastPostCreationTime, postsToFetch) : _postRepository.FetchPostsOfPostType(courseId, postType, lastPostCreationTime, postsToFetch); // Check if can fetch more posts var canFetchMore = !usePostTypeFilter ? _postRepository.CanFetchMore(courseId, lastPostCreationTime) : _postRepository.CanFetchMoreOfPostType(courseId, postType, lastPostCreationTime); // Convert posts to DTOs var postDtos = posts.ToPostViewModel(userId); return(postDtos, canFetchMore); }