Ejemplo n.º 1
0
        private ArticlePartialViewModel CreateArticlePartialViewModel(Article article, bool renderTitleAsLink)
        {
            var permalinkUrl = _urlGenerator.GeneratePermalinkUrl(article.Id);
            var encodedPermalinkUrl = _urlEncoder.EncodeUrl(permalinkUrl);

            return new ArticlePartialViewModel
            {
                Id = article.Id,
                Author = article.Author,
                Content = article.Content,
                Title = article.Title,
                PermalinkUrl = permalinkUrl,
                EditArticleUrl = string.Format(_appConfig.EditArticleUrlFormat, article.Id),
                UserFriendlyPublishDateTime = article.PublishDateTime.ToString(_appConfig.DateTimeFormat),
                ValidHtml5TPublishDateTime = article.PublishDateTime.ToString(_appConfig.HtmlDateTimeFormat),
                TwitterShareUrl = string.Format(_appConfig.TwitterShareUrlFormat, encodedPermalinkUrl),
                GooglePlusShareUrl = string.Format(_appConfig.GooglePlusShareUrlFormat, encodedPermalinkUrl),
                FacebookShareUrl = string.Format(_appConfig.FacebookShareUrlFormat, encodedPermalinkUrl),
                YammerShareUrl = string.Format(_appConfig.YammerShareUrlFormat, encodedPermalinkUrl),
                LinkedInShareUrl = string.Format(_appConfig.LinkedInShareUrlFormat, encodedPermalinkUrl, article.Title),
                WhatsAppShareUrl = string.Format(_appConfig.WhatsAppShareUrlFormat, article.Title, encodedPermalinkUrl),
                RenderTitleAsLink = renderTitleAsLink,
                HasTags = article.Tags != null && article.Tags.Any(),
                Tags = article.Tags
            };
        }
Ejemplo n.º 2
0
 public static void Match(Article expectedArticle, Article actualArticle)
 {
     Assert.AreEqual(expectedArticle.Id, actualArticle.Id);
     Assert.AreEqual(expectedArticle.Author, actualArticle.Author);
     Assert.AreEqual(expectedArticle.Title, actualArticle.Title);
     Assert.AreEqual(expectedArticle.PublishDateTime, actualArticle.PublishDateTime);
     CollectionAssert.AreEqual(expectedArticle.Tags, actualArticle.Tags);
     Assert.AreEqual(expectedArticle.Content, actualArticle.Content);
 }
Ejemplo n.º 3
0
        public SyndicationItem ConvertToFeedItem(Article article, string permalinkUrl)
        {
            var item = new SyndicationItem(
                article.Title,
                new TextSyndicationContent(article.Content, TextSyndicationContentKind.Html),
                new Uri(permalinkUrl),
                article.Id,
                article.PublishDateTime)
            {
                PublishDate = article.PublishDateTime
            };

            if (article.Tags == null || !article.Tags.Any())
                return item;

            foreach (var tag in article.Tags)
            {
                item.Categories.Add(new SyndicationCategory(tag));
            }

            return item;
        }
Ejemplo n.º 4
0
        public ArticleViewModel CreateArticleViewModel(Article article)
        {
            var partialViewModel = CreateArticlePartialViewModel(article, false);

            return new ArticleViewModel(partialViewModel);
        }