public ActionResult DelById(int id, int Page = 1) { string str = ""; string linkname = DNTRequest.GetString("linkname"); hx_td_Links pDel = new hx_td_Links() { Linkid = id }; ef.hx_td_Links.Attach(pDel); ef.hx_td_Links.Remove(pDel); int i = ef.SaveChanges(); if (i > 0) { str = StringAlert.Alert("友情链接删除成功!", "/admin/Link?page=" + Page.ToString() + "&linkname=" + linkname); CacheRemove.ReMovetd_web_Links(); } else { str = StringAlert.Alert("友情链接删除失败!", "/admin/Link?page=" + Page.ToString()); } return(Content(str, "text/html")); }
public ActionResult Edit(hx_td_Links p) { string str = ""; int page = DNTRequest.GetInt("page", 1); string[] proNames; proNames = new string[] { "Linkname", "LinkUrl", "LinkType", "LinkLogo", "Linkstate" }; p = (hx_td_Links)Utils.ValidateModelClass(p); p.LinkLogo.Replace("//", "/"); DbEntityEntry entry = ef.Entry <hx_td_Links>(p); entry.State = EntityState.Unchanged; foreach (string ProName in proNames) { entry.Property(ProName).IsModified = true; } int i = ef.SaveChanges(); if (i > 0) { str = StringAlert.Alert("友情链接修改成功!", "/admin/Link?page=" + page.ToString()); } else { str = StringAlert.Alert("友情链接修改失败!", "/admin/Link/Edit/" + p.Linkid + "/"); } CacheRemove.ReMovetd_web_Links(); return(Content(str, "text/html")); }
public ActionResult AddLinkpost(hx_td_Links p) { p = (hx_td_Links)Utils.ValidateModelClass(p); p.LinkLogo.Replace("//", "/"); p.createtime = DateTime.Now; ef.hx_td_Links.Add(p); ef.SaveChanges(); CacheRemove.ReMovetd_web_Links(); return(RedirectToAction("index", "Link")); }