public async Task <IEnumerable <CommentView <TUserView> > > GetComments(TUser account, int newsId, bool descending = false) { var news = await session.LoadAsync <TThread>(newsId); var comments = (await session.SelectAllFrom <TCommentInThread>(x => x.Comment, x => x.Comment.Author).Where(c => c.Commentable == news).ToListAsync()).Select(x => x.Comment); if (descending) { return(comments.OrderByDescending(c => c.CreationDate).Select(c => commentMapping.ToCommentView(c))); } return(comments.OrderBy(c => c.CreationDate).Select(c => commentMapping.ToCommentView(c))); }
public async Task <CommentView <TUserView> > Get(int id) { return(forumsDataMapping.ToCommentView(await session.LoadAsync <Comment <TUser> >(id))); }