public static IList <Post> GetFeaturedCommentsForArticle(int articleId) { try { return(DiscourseCache.GetOrAdd( "FeaturedCommentsForArticle_" + articleId, () => { Logger.Debug("Getting and caching featured comments for article (ID={0}).", articleId); var api = DiscourseHelper.CreateApi(); return StoredProcs.Articles_GetFeaturedComments(articleId) .Execute() .Select(c => api.GetReplyPost(c.Discourse_Post_Id)) .Where(p => !p.Hidden) .ToList() .AsReadOnly(); } )); } catch (Exception ex) { Logger.Error("Error getting featured comments for article (ID={0}), error: {1}", articleId, ex); return(new Post[0]); } }
public static IList <Post> GetFeaturedCommentsForArticle(int articleId) { try { return(DiscourseCache.GetOrAdd( "FeaturedCommentsForArticle_" + articleId, () => { var api = DiscourseHelper.CreateApi(); return StoredProcs.Articles_GetFeaturedComments(articleId) .Execute() .Select(c => api.GetReplyPost(c.Discourse_Post_Id)) .Where(p => !p.Hidden) .ToList() .AsReadOnly(); } )); } catch { return(new Post[0]); } }
public static IList <CommentModel> GetFeaturedCommentsForArticle(ArticleModel article) { var comments = StoredProcs.Articles_GetFeaturedComments(article.Id).Execute(); return(comments.Select(c => FromTable(c)).ToList()); }