public ActionResult Index(bool json = false) { List <Article> model = new List <Article>(); model = CardillSportsDB.RecentArticles(); if (json) { List <ArticleJson> sendData = new List <ArticleJson>(); if (model.Count > 0) { foreach (Article a in model) { sendData.Add(new ArticleJson(a)); } } return(Json(new { articleList = sendData }, JsonRequestBehavior.AllowGet)); } else { return(View(model)); } }
public ActionResult Articles() { var model = new List <Article>(); model = CardillSportsDB.GetArticles(true); List <ArticleJson> sendData = new List <ArticleJson>(); if (model.Count > 0) { foreach (Article a in model) { sendData.Add(new ArticleJson(a)); } } return(Json(new { articleList = sendData }, JsonRequestBehavior.AllowGet)); }
public ActionResult ViewArticle(int articleID = 0) { var model = new Article(); var targetURL = "articlePage"; model = CardillSportsDB.GetArticle(articleID); if (model == null) { targetURL = "homePage"; model = new Article(); return(Json(new { targetURL = targetURL }, JsonRequestBehavior.AllowGet)); } return(Json(new { articleData = new ArticleJson(model), targetURL = targetURL }, JsonRequestBehavior.AllowGet)); }