Beispiel #1
0
        public string ViewArticlesByDate(int year, int month)
        {
            var date     = new DateTime(year, month, 1);
            var articles = ArticleModel.GetAllArticlesByMonth(date);

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

            return(FormatOutput(articles));
        }
Beispiel #2
0
        public ActionResult ViewArticlesByDate(int year, int month)
        {
            DateTime date;

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

            if (IsEmpty(articles))
            {
                return(ErrorStatus(HttpStatusCode.NotFound, "No articles found for the current date range"));
            }

            return(FormatOutput(articles));
        }