Beispiel #1
0
        public async Task <IList <PostDTO> > GetPostsDTOAsync(int id)
        {
            ISpecification <Post> specification = PostSpecifications.PostsByBlog(id);
            var posts = await _postRepository.AllMatchingAsync(specification);

            if (posts != null && posts.Any())
            {
                return(posts.ProjectedAsCollection <PostDTO>());
            }
            return(null);
        }
Beispiel #2
0
        public async Task <List <PostDTO> > GetAllDTOAsync(string q)
        {
            ISpecification <Post> specification = PostSpecifications.PostsContainsTitleOrContent(q);

            var posts = await _postRepository.AllMatchingAsync(specification);

            if (posts != null && posts.Any())
            {
                return(posts.ProjectedAsCollection <PostDTO>());
            }

            return(null);
        }