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 }); }
private async Task <SyndicationFeed> CreateFeed(string feedUrl) { var articles = await _articleService.GetMostRecentAsync(_maxItemCount).ConfigureAwait(false); var feedItems = articles.Select(article => _feedItemConverter.ConvertToFeedItem( article, _urlGenerator.GeneratePermalinkUrl(article.Id))); var feed = new SyndicationFeed( _feedTitle, _feedDescription, new Uri(feedUrl), feedItems); return(feed); }