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)); }
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)); }