protected override async Task <IEnumerable <SpaceView> > HandleInput(FindByValueParams <string> input) { using (var connection = database.GetConnection()) { ISubscriptionRepo subRepo = database.GetRepo <ISubscriptionRepo>(connection); IEnumerable <Subscription> subs = await subRepo.FindByUser(input.Value); return(subs.Select(s => spaceMapper.Map(s.Space))); } }
protected override async Task <SpaceView?> HandleInput(FindByValueParams <string> input) { using (var connection = database.GetConnection()) { ISpaceRepo spaceRepo = database.GetRepo <ISpaceRepo>(connection); Space?s = await spaceRepo.FindByName(input.Value); return(s != null?spaceMapper.Map(s) : null); } }
protected override async Task <UserView?> HandleInput(FindByValueParams <string> input) { using (var connection = database.GetConnection()) { IUserRepo userRepo = database.GetRepo <IUserRepo>(connection); User? user = await userRepo.FindByUsername(input.Value); if (user == null) { return(null); } return(userMapper.Map(user)); } }
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)); } }
protected async override Task <IEnumerable <CommentView> > HandleInput(FindByValueParams <int> input) { using (var connection = database.GetConnection()) { ICommentRepo commentRepo = database.GetRepo <ICommentRepo>(connection); IEnumerable <Comment> comments = await commentRepo.FindByPost(input.Value); if (input.User != null) { IVoteRepo voteRepo = database.GetRepo <IVoteRepo>(connection); foreach (Comment c in comments) { await GetVotes(voteRepo, c, input.User); } } return(comments.Select(c => commentMapper.Map(c))); } }
protected async override Task <CommentView?> HandleInput(FindByValueParams <int> input) { using (var connection = database.GetConnection()) { ICommentRepo commentRepo = database.GetRepo <ICommentRepo>(connection); Comment?c = await commentRepo.FindById(input.Value); if (c == null) { return(null); } if (input.User != null) { IVoteRepo voteRepo = database.GetRepo <IVoteRepo>(connection); await GetVotes(voteRepo, c, input.User); } return(commentMapper.Map(c)); } }
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 )); } }
protected async override Task <PostView?> HandleInput(FindByValueParams <int> input) { using (var connection = database.GetConnection()) { IPostRepo postRepo = database.GetRepo <IPostRepo>(connection); IVoteRepo voteRepo = database.GetRepo <IVoteRepo>(connection); Post?post = await postRepo.FindById(input.Value); if (post == null) { return(null); } //Pull in the vote if needed. if (input.User != null) { post.Vote = await voteRepo.FindByUserAndPost(input.User.Username, input.Value); } return(postMapper.Map(post)); } }