コード例 #1
0
        public string ViewRecentArticlesBySeriesAndCount(string slug, int count = 8)
        {
            if (count > 100)
            {
                return(ErrorStatus("Count cannot be greater than 100"));
            }

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

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

            return(FormatOutput(articles));
        }
コード例 #2
0
ファイル: ApiController.cs プロジェクト: kazitor/WtfWebApp
        public ActionResult ViewRecentArticlesBySeriesAndCount(string slug, int count = 8)
        {
            if (count > 100)
            {
                return(ErrorStatus(HttpStatusCode.BadRequest, "Count cannot be greater than 100"));
            }

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

            if (IsEmpty(articles))
            {
                return(ErrorStatus(HttpStatusCode.NotFound, SeriesModel.GetSeriesBySlug(slug) == null ? "Invalid Series" : "No articles found"));
            }

            return(FormatOutput(articles));
        }
コード例 #3
0
 public ArticlesIndexViewModel(SeriesModel series, DateTime?reference = null)
 {
     this.Series        = series;
     this.ReferenceDate = new DateInfo(reference ?? ArticleModel.GetRecentArticlesBySeries(series.Slug, 1).FirstOrDefault()?.PublishedDate ?? DateTime.Now);
 }