Esempio n. 1
0
        protected async override Task <PagedResultSet <CommentView> > HandleInput(FindByValueParams <string> input)
        {
            using (var connection = database.GetConnection()) {
                ICommentRepo commentRepo = database.GetRepo <ICommentRepo>(connection);

                PagedResultSet <Comment> comments = await commentRepo.FindByUser(input.Value, input.Pagination?.PageNumber ?? 0, input.Pagination?.PageSize ?? Comment.PageSize);

                if (input.User != null)
                {
                    foreach (Comment c in comments)
                    {
                        IVoteRepo voteRepo = database.GetRepo <IVoteRepo>(connection);
                        await GetVotes(voteRepo, c, input.User);
                    }
                }

                return(new PagedResultSet <CommentView>(
                           comments.Select(c => commentMapper.Map(c)),
                           comments.Pagination
                           ));
            }
        }