public async Task <PostViewModel> GetPostByIdAsync(string postId) { var post = await _postRepository.GetByConditionAsync <PostViewModel>(x => x.Id == postId, PostHelpers.GetPostMapperConfiguration()); Guard.Against.NullItem(post, nameof(post)); return(post); }
public async Task <IEnumerable <PostViewModel> > GetNewsFeedPosts(string userId, PostSearchParams searchParams) { Community community = await _communityRepository.GetByConditionAsync(x => x.Name == searchParams.CommunityName); Guard.Against.NullItem(community, nameof(community)); searchParams.Followers = await _userRepository.ListUserFollowingsAsync(userId); var specification = new PostFilterSpecification(searchParams); return(await _postRepository.ListAsync <PostViewModel>(specification, PostHelpers.GetPostMapperConfiguration())); }
public async Task <IEnumerable <PostViewModel> > GetPostsAsync(PostSearchParams searchParams) { User user = await _userManager.FindByIdAsync(searchParams.UserId); Guard.Against.NullItem(user, nameof(user)); Community community = await _communityRepository.GetByConditionAsync(x => x.Name == searchParams.CommunityName); Guard.Against.NullItem(community, nameof(community)); var specification = new PostFilterSpecification(searchParams); return(await _postRepository.ListAsync <PostViewModel>(specification, PostHelpers.GetPostMapperConfiguration())); }