public ArticlePage( ArticleSlug articleSlug, Article article, ArticleRevision articleRevision = null, ArticleRedirect articleRedirect = null) : base(articleSlug, article, articleRevision, articleRedirect) { this.PopulateArticleRevision(articleRevision); }
private void PopulateArticleRevision(ArticleRevision articleRevision) { if (articleRevision == null) { return; } this.ArticleRevisionMarkdownContent = articleRevision.MarkdownContent; }
public static string CreateArticleRevisionId(ArticleRevision articleRevision) { if (articleRevision == null) { throw new ArgumentNullException("articleRevision"); } return(CreateArticleRevisionId(articleRevision.ArticleId, articleRevision.CreatedAt)); }
public ArticleResult SaveArticleRevision( ArticleId articleId, ArticleRevision articleRevision, bool publishRevision = false) { if (articleId == null) { throw new ArgumentNullException("articleId"); } if (articleRevision == null) { throw new ArgumentNullException("articleRevision"); } var article = this.GetArticle(articleId) ?? new Article(articleId); return(this.SaveArticle(article, articleRevision, publishRevision)); }
public ArticlePageBase( ArticleSlug articleSlug, Article article, ArticleRevision articleRevision = null, ArticleRedirect articleRedirect = null) { this.ArticleSlug = articleSlug; PopulateArticle(article); PopulateArticleRevision(articleRevision); PopulateArticleRedirect(articleRedirect); this.ArticleAccess = this.ArticleAccess ?? ArticleAccess.Default(); this.ArticleSlug = this.ArticleSlug ?? ArticleSlug.Empty; this.ArticleTags = this.ArticleTags ?? Enumerable.Empty<string>(); this.ArticleRevisionDate = this.ArticleRevisionDate ?? ArticleRevisionDate.Empty; this.RedirectedFromArticleSlug = this.RedirectedFromArticleSlug ?? ArticleSlug.Empty; this.ArticleRevisionOutboundArticleSlugs = this.ArticleRevisionOutboundArticleSlugs ?? Enumerable.Empty<string>(); }
public ArticleResult SaveArticle( Article article, ArticleRevision articleRevision = null, bool publishRevision = false) { if (article == null) { throw new ArgumentNullException("article"); } if (string.IsNullOrWhiteSpace(article.Id)) { this.CurrentSession.Store(article); } this.SaveArticleRevisionInternal(article, articleRevision, publishRevision); this.RemoveArticleRedirect(article); this.CurrentSession.SaveChanges(); return(new ArticleResult(article, articleRevision)); }
private void SaveArticleRevisionInternal(Article article, ArticleRevision articleRevision, bool publishRevision) { if (articleRevision == null || string.IsNullOrWhiteSpace(articleRevision.MarkdownContent)) { return; } var activeRevision = this.GetArticleRevision(article.ActiveRevisionId); if (activeRevision != null && activeRevision.MarkdownContent == articleRevision.MarkdownContent) { return; } articleRevision.ArticleId = article.Id; this.CurrentSession.Store(articleRevision); if (publishRevision) { article.ActiveRevisionId = articleRevision.Id; articleRevision.LastPublishedAt = DateTime.UtcNow; } }
public ArticleRevision SaveArticleRevision(ArticleSlug articleSlug, string markdownContent, string editSummary) { AssertArticleSlug(articleSlug); var article = this.TryGetArticle(articleSlug) ?? new Article(articleSlug); this.SaveArticle(article); var articleRevision = new ArticleRevision( articleSlug, this.currentPrincipal, this.currentIpAddress, markdownContent, editSummary); if (string.IsNullOrWhiteSpace(markdownContent)) { return null; } var activeArticleRevision = this.GetLatestArticleRevision(article.Id); bool isContentEqualToActiveRevision = (activeArticleRevision != null) && (activeArticleRevision.MarkdownContent == articleRevision.MarkdownContent); if (isContentEqualToActiveRevision) { return null; } articleRevision.ArticleId = article.Id; this.CurrentSession.Store(articleRevision); article.ActiveArticleRevisionId = articleRevision.Id; return articleRevision; }
private void PopulateArticleRevision(ArticleRevision articleRevision) { if (articleRevision == null) { return; } this.ArticleRevisionId = articleRevision.Id; this.ArticleRevisionEditSummary = articleRevision.EditSummary; this.ArticleRevisionOutboundArticleSlugs = articleRevision.OutboundArticleSlugs; }