public ActionResult DelById(int id, int Page = 1, int rootid = 0, string news_title = "") { string str = ""; hx_td_about_news pDel = new hx_td_about_news() { newid = id }; ef.hx_td_about_news.Attach(pDel); ef.hx_td_about_news.Remove(pDel); int i = ef.SaveChanges(); if (i > 0) { CacheRemove.RemoveWebCache("NewsList"); str = StringAlert.Alert("帮助中心删除成功!", "/admin/Help/Index?page=" + Page.ToString() + "&rootid=" + rootid.ToString() + "&news_title=" + news_title); } else { str = StringAlert.Alert("帮助中心删除失败!", "/admin/Help/Index?page=" + Page.ToString() + "&rootid=" + rootid.ToString() + "&news_title=" + news_title); } return(Content(str, "text/html")); }
public ActionResult AddHelpPost(hx_td_about_news p, int rootid, string context) { p = (hx_td_about_news)Utils.ValidateModelClass(p); p.context = context; p.createtime = DateTime.Now; p.newimg = p.newimg.Replace("//", "/"); p.comm = 0; p.listcomm = 0; p.adminuserid = 0; ef.hx_td_about_news.Add(p); //ef.SaveChanges(); string str = ""; int i = ef.SaveChanges(); if (i > 0) { CacheRemove.RemoveWebCache("NewsList"); str = StringAlert.Alert("添加成功!", "/admin/Help/Index?rootid=" + rootid); } else { str = StringAlert.Alert("添加失败!", "/admin/Help/Add?rootid=" + rootid); } return(Content(str, "text/html")); }
public ActionResult EditHelpPost(hx_td_about_news p, int rootid = 0, int page = 1, string context = "") { string str = ""; string[] proNames; proNames = new string[] { "News_title", "web_Type_menu_id", "News_Key", "news_Des", "context" }; p = (hx_td_about_news)Utils.ValidateModelClass(p); p.context = context; p.newimg = p.newimg.Replace("//", "/"); DbEntityEntry entry = ef.Entry <hx_td_about_news>(p); entry.State = EntityState.Unchanged; foreach (string ProName in proNames) { entry.Property(ProName).IsModified = true; } int i = ef.SaveChanges(); if (i > 0) { CacheRemove.RemoveWebCache("NewsList"); str = StringAlert.Alert("帮助中心修改成功!", "/Admin/help/index?page=" + page + "&rootid=" + rootid); } else { str = StringAlert.Alert("帮助中心修改失败!", "/admin/help/Edit?id=" + p.newid + "&rootid=" + rootid + "&page=" + page); } return(Content(str, "text/html")); }
/// 增加文章点击量 public void ProcessRequest(HttpContext context) { int id = Convert.ToInt32(context.Request.QueryString["id"]); if (id != 0) { chuangtouEntities TF = new chuangtouEntities(); hx_td_about_news ha = TF.hx_td_about_news.Where(p => p.newid == id).FirstOrDefault(); if (ha != null) { ha.ClickCount = (ha.ClickCount == null ? 0 : ha.ClickCount) + 1; TF.SaveChanges(); } } }