Exemple #1
0
        public ArticleId(string articleIdOrSlugOrTitle)
        {
            if (articleIdOrSlugOrTitle == null)
            {
                throw new ArgumentNullException("articleIdOrSlugOrTitle");
            }

            this.hasValueLazy = new Lazy <bool>(() => (!string.IsNullOrWhiteSpace(articleIdOrSlugOrTitle)));

            string articleIdOrSlug = ArticleSlugUtility.Decode(articleIdOrSlugOrTitle);

            bool isId = GetIsId(articleIdOrSlug);

            if (isId)
            {
                this.originalSlugLazy = this.slugLazy;
                this.slugLazy         = new Lazy <string>(() => GetArticleSlug(articleIdOrSlug));
            }
            else
            {
                this.originalSlugLazy = new Lazy <string>(() => articleIdOrSlugOrTitle);
                this.slugLazy         = new Lazy <string>(() => ArticleSlugUtility.Encode(articleIdOrSlug));
            }

            this.idLazy = new Lazy <string>(() => IdUtility.CreateArticleId(this.slugLazy.Value));

            this.titleLazy = new Lazy <string>(() => ArticleSlugUtility.Decode(this.slugLazy.Value));
        }
Exemple #2
0
        public ArticleResult GetArticleResult(ArticleId articleId, DateTime?revisionDate = null)
        {
            if (articleId == null)
            {
                throw new ArgumentNullException("articleId");
            }

            ArticleRedirect articleRedirect = null;

            var article = this.CurrentSession.Include <Article>(x => x.ActiveRevisionId).Load(articleId.Id);

            if (article == null)
            {
                articleRedirect = this.GetArticleRedirect(articleId);
                if (articleRedirect != null)
                {
                    article = this.GetArticle(articleRedirect.RedirectToArticleSlug);
                }
            }

            string articleRevisionId = revisionDate.HasValue
                                           ? IdUtility.CreateArticleRevisionId(articleId, revisionDate.Value)
                                           : ((article != null) ? article.ActiveRevisionId : null);

            var articleRevision = this.GetArticleRevision(articleRevisionId);

            return(new ArticleResult(article, articleRevision, articleRedirect));
        }
Exemple #3
0
        public ArticleRevision GetArticleRevision(ArticleId articleId, ArticleRevisionDate revisionDate)
        {
            string id = (articleId != null) ? articleId.Id : null;

            string articleRevisionId = IdUtility.CreateArticleRevisionId(id, revisionDate);

            return(this.GetArticleRevision(articleRevisionId));
        }
Exemple #4
0
        public ArticleRedirect GetArticleRedirect(ArticleId originalArticleId)
        {
            string articleRedirectId = IdUtility.CreateArticleRedirectId(originalArticleId);

            return(this.CurrentSession.Load <ArticleRedirect>(articleRedirectId));
        }