Ejemplo n.º 1
0
        private IEnumerable <ArticleItemViewModel> GetArticles()
        {
            if (this.ReferenceDate != null)
            {
                return(ArticleModel.GetAuthorArticlesByMonth(this.Author.Slug, this.ReferenceDate.Reference)
                       .Select(a => new ArticleItemViewModel(a)));
            }

            return(ArticleModel.GetRecentArticlesByAuthor(this.Author.Slug)
                   .Select(a => new ArticleItemViewModel(a)));
        }
Ejemplo n.º 2
0
        public ActionResult ViewRecentArticlesByAuthorAndCount(string slug, int count = 8)
        {
            if (count > 100)
            {
                return(ErrorStatus(HttpStatusCode.BadRequest, "Count cannot be greater than 100"));
            }

            var articles = ArticleModel.GetRecentArticlesByAuthor(slug, count);

            if (IsEmpty(articles))
            {
                return(ErrorStatus(HttpStatusCode.NotFound, "Invalid Author"));
            }

            return(FormatOutput(articles));
        }
Ejemplo n.º 3
0
        public string ViewRecentArticlesByAuthorAndCount(string slug, int count = 8)
        {
            if (count > 100)
            {
                return(ErrorStatus("Count cannot be greater than 100"));
            }

            var articles = ArticleModel.GetRecentArticlesByAuthor(slug, count);

            if (IsEmpty(articles))
            {
                return(ErrorStatus("Invalid Author"));
            }

            return(FormatOutput(articles));
        }
Ejemplo n.º 4
0
 public MyArticlesViewModel(string authorSlug)
 {
     this.UnpublishedArticles     = ArticleModel.GetUnpublishedArticles(authorSlug);
     this.RecentPublishedArticles = ArticleModel.GetRecentArticlesByAuthor(authorSlug, this.MaxPublishedArticleCount);
 }