コード例 #1
0
ファイル: DiscourseHelper.cs プロジェクト: hifi/WtfWebApp
        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]);
            }
        }
コード例 #2
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]);
            }
        }
コード例 #3
0
        public static IList <CommentModel> GetFeaturedCommentsForArticle(ArticleModel article)
        {
            var comments = StoredProcs.Articles_GetFeaturedComments(article.Id).Execute();

            return(comments.Select(c => FromTable(c)).ToList());
        }