Exemplo n.º 1
0
        /// <summary>
        /// Gets the social network URLs and share counts for the specified post
        /// </summary>
        /// <param name="post">Post to get statistics on</param>
        /// <returns>Social network URLs and share counts for the post</returns>
        private IEnumerable <PostSocialNetworkModel> GetSocialNetworks(PostModel post)
        {
            var shareCounts    = post.ShareCounts ?? new Dictionary <string, int>();
            var socialNetworks = _socialManager.ShareUrls(post, Url.BlogPostAbsolute(post), ShortUrl(post));

            return(socialNetworks.Select(x => new PostSocialNetworkModel
            {
                SocialNetwork = x.Key,
                Url = x.Value,
                Count = shareCounts.ContainsKey(x.Key.Id) ? shareCounts[x.Key.Id] : 0
            }));
        }