Example #1
0
        public string ViewArticlesBySeriesAndDate(string slug, int year, int month)
        {
            var date     = new DateTime(year, month, 1);
            var articles = ArticleModel.GetSeriesArticlesByMonth(slug, date);

            if (IsEmpty(articles))
            {
                return(ErrorStatus("No articles found for the current date range or Invalid Series"));
            }

            return(FormatOutput(articles));
        }
Example #2
0
        public ActionResult ViewArticlesBySeriesAndDate(string slug, int year, int month)
        {
            DateTime date;

            try
            {
                date = new DateTime(year, month, 1);
            }
            catch (ArgumentOutOfRangeException)
            {
                return(ErrorStatus(HttpStatusCode.BadRequest, "Invalid date"));
            }
            var articles = ArticleModel.GetSeriesArticlesByMonth(slug, date);

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

            return(FormatOutput(articles));
        }
        public ArticlesIndexViewModel()
        {
            this.ReferenceDate = new DateInfo(DateTime.Now);

            this.getArticles = new Lazy <IEnumerable <ArticleItemViewModel> >(() => ArticleModel.GetSeriesArticlesByMonth(this.Series?.Slug, this.ReferenceDate.Reference).Select(a => new ArticleItemViewModel(a)).ToList());
        }