public JsonResult DelArticleCategory(int id) { ArticleCategory entity = ArticleCategory.Find(ArticleCategory._.Id == id); if (entity == null) { tip.Message = "系统找不到本文章栏目!"; return(Json(tip)); } if (ArticleCategory.FindCount(ArticleCategory._.PId == entity.Id, null, null, 0, 0) > 0) { tip.Message = "本栏目有下级栏目,不允许删除!"; return(Json(tip)); } //删除文章 IList <Article> list = Article.FindAll(Article._.KId == entity.Id, null, null, 0, 0); if (list != null && list.Count > 0) { list.Delete(); } Core.Admin.WriteLogActions("删除文章栏目(id:" + entity.Id + ");"); entity.Delete(); tip.Status = JsonTip.SUCCESS; tip.Message = "删除文章栏目成功"; return(Json(tip)); }
//Handle the delete button click event public void Delete_Category(Object sender, RepeaterCommandEventArgs e) { if ((e.CommandName == "Delete")) { //Instantiate article delete object ArticleCategory DelCat = new ArticleCategory(); DelCat.CatID = Convert.ToInt32(e.CommandArgument); Caching.PurgeCacheItems("ArticleCategory_SideMenu"); //Perform delete DelCat.Delete(); //Redirect to confirm delete page Response.Redirect("confirmarticlecatedit.aspx?catname=ArticleCategoryID" + DelCat.CatID + "&mode=del"); } }