Exemple #1
0
        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);
        }
Exemple #2
0
        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()));
        }
Exemple #3
0
        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()));
        }