Exemple #1
0
        /// <summary>
        /// Gets all blog post tags
        /// </summary>
        /// <param name="languageId">Language identifier. 0 if you want to get all news</param>
        /// <returns>Blog post tags</returns>
        public static List <BlogPostTag> GetAllBlogPostTags(int languageId)
        {
            List <BlogPostTag> blogPostTags = new List <BlogPostTag>();

            var blogPostsAll = GetAllBlogPosts(languageId);

            foreach (var blogPost in blogPostsAll)
            {
                var tags = blogPost.ParsedTags;
                foreach (string tag in tags)
                {
                    var foundBlogPostTag = blogPostTags.Find(bpt => bpt.Name.Equals(tag, StringComparison.InvariantCultureIgnoreCase));
                    if (foundBlogPostTag == null)
                    {
                        foundBlogPostTag = new BlogPostTag()
                        {
                            Name          = tag,
                            BlogPostCount = 1
                        };
                        blogPostTags.Add(foundBlogPostTag);
                    }
                    else
                    {
                        foundBlogPostTag.BlogPostCount++;
                    }
                }
            }

            return(blogPostTags);
        }
Exemple #2
0
        /// <summary>
        /// Gets all blog post tags
        /// </summary>
        /// <param name="languageId">Language identifier. 0 if you want to get all news</param>
        /// <returns>Blog post tags</returns>
        public static List<BlogPostTag> GetAllBlogPostTags(int languageId)
        {
            var blogPostTags = new List<BlogPostTag>();

            List<BlogPost> blogPostsAll = GetAllBlogPosts(languageId);
            foreach (BlogPost blogPost in blogPostsAll)
            {
                string[] tags = blogPost.ParsedTags;
                foreach (string tag in tags)
                {
                    BlogPostTag foundBlogPostTag =
                        blogPostTags.Find(bpt => bpt.Name.Equals(tag, StringComparison.InvariantCultureIgnoreCase));
                    if (foundBlogPostTag == null)
                    {
                        foundBlogPostTag = new BlogPostTag
                                               {
                                                   Name = tag,
                                                   BlogPostCount = 1
                                               };
                        blogPostTags.Add(foundBlogPostTag);
                    }
                    else
                    {
                        foundBlogPostTag.BlogPostCount++;
                    }
                }
            }

            return blogPostTags;
        }