private async Task <IList <IPost> > GetPosts(PostQuerySettings settings) { IList <IPost> posts = dataContext.PostGateway.Find(x => true); switch (settings) { case PostQuerySettings.Empty: return(posts); case PostQuerySettings.Full: foreach (IPost post in posts) { post.LikesCollection = await LoadRelatedLikesAsync(post.Id); post.CommentsCollection = await LoadRelatedCommentsAsync(post.Id); } break; case PostQuerySettings.WithLikes: foreach (IPost post in posts) { post.LikesCollection = await LoadRelatedLikesAsync(post.Id); } break; default: break; } return(posts); }
private async Task <IPost> GetPostAsync(string postId, PostQuerySettings settings) { IPost post = dataContext.PostGateway.FindById(postId); switch (settings) { case PostQuerySettings.Empty: break; case PostQuerySettings.Full: post.LikesCollection = await LoadRelatedLikesAsync(post.Id); post.CommentsCollection = await LoadRelatedCommentsAsync(post.Id); break; case PostQuerySettings.WithLikes: post.LikesCollection = await LoadRelatedLikesAsync(post.Id); break; default: break; } return(post); }
public GetAllPostsQuery(PostQuerySettings settings) { Settings = settings; }
public async Task <IList <IPost> > GetAllPostsAsync(PostQuerySettings settings) { return(await mediator.Send(new GetAllPostsQuery(settings))); }
public async Task <IPost> GetSinglePost(string postId, PostQuerySettings settings) { return(await mediator.Send(new GetSinglePostQuery(postId, settings))); }
public GetSinglePostQuery(string id, PostQuerySettings settings = PostQuerySettings.Empty) { Id = id; Settings = settings; }