public ActionResult Modify() { GrassrootNews g = new GrassrootNews(); g.grassrootNews_id = int.Parse(Request.Form["id"]); g.grassrootNews_title = Request.Form["title"]; g.grassrootNews_author = Request.Form["author"]; g.grassrootNews_source = Request.Form["from"]; g.grassrootNews_abstract = Request.Form["abstract"]; g.grassrootNews_release_time = DateTime.Now; String text = Request.Form["text"]; text = text.Replace("#lt;", "<"); text = text.Replace("#gt;", ">"); g.grassrootNews_content = text; int categoryId = int.Parse(Request.Form["classify"]); g.district_id = categoryId; if (ModelState.IsValid) { gn.Entry(g).State = EntityState.Modified; gn.SaveChanges(); } return(Content("修改成功")); }
public ActionResult PublishNews() { GrassrootNews g = new GrassrootNews(); g.grassrootNews_title = Request.Form["title"]; g.grassrootNews_author = Request.Form["author"]; g.grassrootNews_source = Request.Form["from"]; g.grassrootNews_abstract = Request.Form["abstract"]; g.grassrootNews_release_time = DateTime.Now; String text = Request.Form["text"]; text = text.Replace("#lt;", "<"); text = text.Replace("#gt;", ">"); g.grassrootNews_content = text; int categoryId = int.Parse(Request.Form["classify"]); g.district_id = categoryId; g.disTrict = gn.DistrictLists.Find(categoryId); if (ModelState.IsValid) { gn.grassrootNewsLists.Add(g); gn.SaveChanges(); } return(Content("发布成功")); }
public ActionResult Delete(int id) { GrassrootNews g = gn.grassrootNewsLists.Find(id); gn.grassrootNewsLists.Remove(g); gn.SaveChanges(); return(Content("删除成功")); }
public ActionResult DeleteMore() { GrassrootNews g = null; String data = Request.Form["ids"]; String[] ids = data.Split(','); for (int i = 0; i < ids.Length; i++) { g = gn.grassrootNewsLists.Find(int.Parse(ids[i])); gn.grassrootNewsLists.Remove(g); gn.SaveChanges(); } return(Content("删除成功")); }
public ActionResult ModifyPage(int id) { GrassrootNews g = gn.grassrootNewsLists.Find(id); return(View(g)); }
public ActionResult GrassrootDetail(int id) { GrassrootNews singleNews = grassNewsContext.grassrootNewsLists.Find(id); return(View(singleNews)); }