public JsonResult ArticleInfo(string ArticleType_Name, int limit, int offset) { var article = from a in db.Article join b in db.ArticleType on a.ArticleType_ID equals b.ArticleType_ID into JionedEmpDept from ab in JionedEmpDept.DefaultIfEmpty() join c in db.User_Card on a.UserCard_ID equals c.UserCard_ID into JionedEmpDeptac from ac in JionedEmpDeptac.DefaultIfEmpty() orderby a.Article_CreateDT descending //where ab.ArticleType_Name.Contains(ArticleType_Name) select new { ID = a.Article_ID, 文章标题 = a.Article_Title, 文章描述 = a.Article_Abstract, 文章内容 = a.Article_Content, 文章封面 = a.Article_Img, 创建时间 = a.Article_CreateDT.ToString("yyyy/MM/dd"), 文章标签 = a.Lable_ID, 文章类型 = ab.ArticleType_Name, 文章作者 = ac.UserCard_Nickname }; var total = article.Count(); var rows = article.Where(x => x.文章类型.Contains(ArticleType_Name)).Skip(offset).Take(limit).ToList(); return(Json(new { total = total, rows = rows }, JsonRequestBehavior.AllowGet)); }
public ActionResult Article_Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } else { if (id == 0) { ViewBag.state = ""; } else { var article = from a in db.Article join b in db.ArticleType on a.ArticleType_ID equals b.ArticleType_ID into JionedEmpDept from ab in JionedEmpDept.DefaultIfEmpty() join c in db.User_Card on a.UserCard_ID equals c.UserCard_ID into JionedEmpDeptac from ac in JionedEmpDeptac.DefaultIfEmpty() where a.Article_ID == id select new { ID = a.Article_ID, 文章标题 = a.Article_Title, 文章描述 = a.Article_Abstract, 文章内容 = a.Article_Content, 文章封面 = a.Article_Img, 创建时间 = a.Article_CreateDT, 文章标签 = a.Lable_ID, 文章类型 = ab.ArticleType_Name, 文章作者 = ac.UserCard_Nickname }; foreach (var i in article) { ViewData["文章标题"] = i.文章标题; ViewData["文章描述"] = i.文章描述; ViewData["文章内容"] = i.文章内容.ToString(); ViewData["创建时间"] = i.创建时间; var lables = i.文章标签.Split(','); string LablesID_str = ""; foreach (var lable in lables) { LablesID_str = LablesID_str + db.Lable.Where(x => x.Lable_ID.ToString() == lable).Select(x => x.Lable_Text).FirstOrDefault() + ","; } ViewData["文章标签"] = LablesID_str; ViewData["文章类型"] = i.文章类型; ViewData["文章作者"] = i.文章作者; ViewData["文章封面"] = i.文章封面; ViewBag.Labe = LablesID_str; } ViewBag.state = id; } } //ViewBag.state = ""; return(View()); //return Content(id.ToString()); }
public JsonResult ArticleInfo_ALL(int limit, int offset, string SearchArticleName, string SearchArticleTypeName, int id) { var ArticleInfoALL = from a in db.Article join b in db.ArticleType on a.ArticleType_ID equals b.ArticleType_ID into JionedEmpDept from ab in JionedEmpDept.DefaultIfEmpty() join c in db.User_Card on a.UserCard_ID equals c.UserCard_ID into JionedEmpDeptac from ac in JionedEmpDeptac.DefaultIfEmpty() where a.Article_Title.Contains(SearchArticleName) && ab.ArticleType_Name.Contains(SearchArticleTypeName) select new { ID = a.Article_ID, 文章标题 = a.Article_Title, 文章描述 = a.Article_Abstract, 文章内容 = a.Article_Content, 文章封面 = a.Article_Img, 创建时间 = a.Article_CreateDT.ToString("yyyy/MM/dd"), 文章标签 = a.Lable_ID, 文章类型 = ab.ArticleType_Name, 文章作者 = ac.UserCard_Nickname, UCID = ac.UserLogin_ID }; if (id == 0) { } else { ArticleInfoALL = from a in ArticleInfoALL where a.UCID == id select a; } var total = ArticleInfoALL.ToList().Count; var rows = ArticleInfoALL.Skip(offset).Take(limit).ToList(); return(Json(new { total = total, rows = rows }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 文章详细表 /// </summary> /// <param name="id">文章ID</param> /// <returns></returns> public ActionResult ArticleInfo_ID(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } else { if (id == 0) { var article = from a in db.Article join b in db.ArticleType on a.ArticleType_ID equals b.ArticleType_ID into JionedEmpDept from ab in JionedEmpDept.DefaultIfEmpty() join c in db.User_Card on a.UserCard_ID equals c.UserCard_ID into JionedEmpDeptac from ac in JionedEmpDeptac.DefaultIfEmpty() //where ab.ArticleType_Name.Contains(ArticleType_Name) select new { ID = a.Article_ID, 文章标题 = a.Article_Title, 文章描述 = a.Article_Abstract, 文章内容 = a.Article_Content, 文章封面 = a.Article_Img, 创建时间 = a.Article_CreateDT, 文章标签 = a.Lable_ID, 文章类型 = ab.ArticleType_Name, 文章作者 = ac.UserCard_Nickname }; foreach (var i in article) { ViewBag.Article_ID = i.ID; ViewData["文章标题"] = i.文章标题; ViewData["文章描述"] = i.文章描述; ViewData["文章内容"] = i.文章内容.ToString(); ViewData["创建时间"] = i.创建时间; string[] lables = i.文章标签.ToString().Split(','); string[] lablestr = new string[lables.Length]; for (int a = 0; a < lables.Length; a++) { int lableID = int.Parse(lables[a]); lablestr[a] = db.Lable.Where(x => x.Lable_ID == lableID).Select(x => x.Lable_Text).FirstOrDefault(); } ViewData["文章标签"] = lablestr; ViewData["文章类型"] = i.文章类型; ViewData["文章作者"] = i.文章作者; } } else { var article = from a in db.Article join b in db.ArticleType on a.ArticleType_ID equals b.ArticleType_ID into JionedEmpDept from ab in JionedEmpDept.DefaultIfEmpty() join c in db.User_Card on a.UserCard_ID equals c.UserCard_ID into JionedEmpDeptac from ac in JionedEmpDeptac.DefaultIfEmpty() where a.Article_ID == id select new { ID = a.Article_ID, 文章标题 = a.Article_Title, 文章描述 = a.Article_Abstract, 文章内容 = a.Article_Content, 文章封面 = a.Article_Img, 创建时间 = a.Article_CreateDT, 文章标签 = a.Lable_ID, 文章类型 = ab.ArticleType_Name, 文章作者 = ac.UserCard_Nickname }; foreach (var i in article) { ViewBag.Article_ID = i.ID; ViewData["文章标题"] = i.文章标题; ViewData["文章描述"] = i.文章描述; ViewData["文章内容"] = i.文章内容.ToString(); ViewData["创建时间"] = i.创建时间; string[] lables = i.文章标签.ToString().Split(','); string[] lablestr = new string[lables.Length]; for (int a = 0; a < lables.Length; a++) { //int lableID = int.Parse(lables[a+1]); lablestr[a] = db.Lable.Where(x => x.Lable_ID.ToString() == lables[a]).Select(x => x.Lable_Text).FirstOrDefault(); } ViewData["文章标签"] = lablestr; ViewData["文章类型"] = i.文章类型; ViewData["文章作者"] = i.文章作者; ViewBag.Labe = lablestr; } } } return(View()); }