예제 #1
0
        protected override async Task <PagedResultSet <SpaceView> > HandleInput(FindParams input)
        {
            using (var connection = database.GetConnection()) {
                ISpaceRepo spaceRepo = database.GetRepo <ISpaceRepo>(connection);

                PagedResultSet <Space> spaces = await spaceRepo.Find(input.Pagination?.PageNumber ?? 0, input.Pagination?.PageSize ?? Post.PageSize);

                return(new PagedResultSet <SpaceView>(spaces.Select(s => mapper.Map(s)), spaces.Pagination));
            }
        }
예제 #2
0
        protected override async Task <IEnumerable <SpaceView> > HandleInput(FindParams input)
        {
            using (var connection = database.GetConnection()) {
                ISpaceRepo spaceRepo = database.GetRepo <ISpaceRepo>(connection);

                IEnumerable <Space> spaces = await spaceRepo.FindDefault();

                return(spaces.Select(s => spaceMapper.Map(s)));
            }
        }
예제 #3
0
        protected override async Task <PagedResultSet <PostView> > HandleInput(FindParams input)
        {
            using (var connection = database.GetConnection()) {
                IPostRepo postRepo = database.GetRepo <IPostRepo>(connection);
                IVoteRepo voteRepo = database.GetRepo <IVoteRepo>(connection);

                PagedResultSet <Post> posts = await postRepo.FindByNew(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 => mapper.Map(p)), posts.Pagination));
            }
            #endregion
        }