public ContentResult MenusToEdit(B_Menu menu) { menu.IsShow = Request["IsShow"] != null && Request["IsShow"].ToString() == "on" ? true : false; menu.IsValid = Request["IsValid"] != null && Request["IsValid"].ToString() == "on" ? true : false; menu.IsRobot = Request["IsRobot"] != null && Request["IsRobot"].ToString() == "on" ? false : true; if (string.IsNullOrWhiteSpace(menu.MenuName)) { return(Content("名称不能为空")); } if (RepeatHelper.NoRepeat("B_Menu", "MenuName", menu.MenuName, menu.ID) > 0) { return(Content("菜单名已存在")); } if (!string.IsNullOrWhiteSpace(menu.MenuUrl) && RepeatHelper.NoRepeat("B_Menu", "MenuUrl", menu.MenuUrl, menu.ID) > 0) { return(Content("菜单链接已存在")); } int rtn = menu.UpdateByID(); if (rtn > 0) { bool hasMainMenuTag = false; bool hasError = false; List <B_MenuRights> muRights = null; if (string.IsNullOrWhiteSpace(menu.MenuUrl) == false) { menu.MenuUrl = menu.MenuUrl.Trim().TrimEnd('/'); try { string tmpUrl = menu.MenuUrl.TrimStart('/').Split('?')[0]; string[] arrUrl = tmpUrl.Split('/'); Type type = Type.GetType("WeBusiness.Controllers." + arrUrl[0] + "Controller"); muRights = BaseAuthorizeHelper.GetBOMenuRightsByControllerType(type, arrUrl[1], out hasMainMenuTag); } catch (Exception ex) { DAL.Log.Instance.Write(ex.ToString(), "BOMenu_Update"); hasError = true; } } if (hasMainMenuTag && muRights != null) { B_MenuRights.RelevanceList(menu.ID, muRights); } if (hasError) { return(Content("修改菜单成功,但菜单没有添加权限!")); } B_MenuRights.ClearHashMenuRights(); return(Content("ok")); } return(Content("保存出错")); }
public ContentResult IsModuleShow(int id) { B_Menu menu = B_Menu.GetEntityByID(id); menu.IsValid = true; menu.IsShow = true; menu.IsRobot = false; if (menu.UpdateByID() > 0) { return(Content("ok")); } return(Content("启用出错")); }
public ContentResult MenusToUnValid(int id) { B_Menu menu = B_Menu.GetEntityByID(id); menu.IsValid = false; menu.IsShow = false; menu.IsRobot = true; if (menu.UpdateByID() > 0) { return(Content("ok")); } return(Content("停用出错")); }