Example #1
0
        protected override async Task <PagedResultSet <PostView> > HandleInput(FindByValueParams <string> input)
        {
            using (var connection = database.GetConnection()) {
                IPostRepo postRepo = database.GetRepo <IPostRepo>(connection);
                IVoteRepo voteRepo = database.GetRepo <IVoteRepo>(connection);

                PagedResultSet <Post> posts = await postRepo.FindByUser(input.Value, input.Pagination?.PageNumber ?? 0, input.Pagination?.PageSize ?? Post.PageSize);

                if (input.User != null)
                {
                    foreach (Post p in posts)
                    {
                        p.Vote = await voteRepo.FindByUserAndPost(input.User.Username, p.Id);
                    }
                }

                return(new PagedResultSet <PostView>(posts.Items.Select(p => postMapper.Map(p)), posts.Pagination));
            }
        }