コード例 #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)));
        }
コード例 #2
0
ファイル: ApiController.cs プロジェクト: kazitor/WtfWebApp
        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));
        }
コード例 #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));
        }
コード例 #4
0
 public MyArticlesViewModel(string authorSlug)
 {
     this.UnpublishedArticles     = ArticleModel.GetUnpublishedArticles(authorSlug);
     this.RecentPublishedArticles = ArticleModel.GetRecentArticlesByAuthor(authorSlug, this.MaxPublishedArticleCount);
 }