public Task <IReadOnlyList <PostViewModel> > GetPostByUserIdAsync(int userId) { var spec = new PostSpecial(userId, 0, 20); var posts = _postRepository.SelectAsync(spec, post => _mapper.Map <PostViewModel>(post), false); return(posts); }
public Task <Response <IReadOnlyList <PostListItem> > > GetByTagNameAsync(string tagName, int pageSize = 20, int pageIndex = 1) { return(TryExecuteAsync <IReadOnlyList <PostListItem> >(async() => { if (string.IsNullOrEmpty(tagName)) { throw new NullReferenceException("Tag name is required"); } var special = new PostSpecial(tagName, (pageIndex - 1) * pageSize, pageSize); var posts = await _postRepository.SelectAsync(special, post => _mapper.Map <PostListItem>(post)); return new SuccessResponse <IReadOnlyList <PostListItem> >(posts); })); }