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); }
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); }