public ActionResult ChangeAction() { int actionid = Request["actioid"] != null?int.Parse(Request["actioid"]) : 0; int roleid = Request["roleid"] != null?int.Parse(Request["roleid"]) : 0; bool isAllow = Request["isAllow"].ToString() == "true" ? true : false; if (isAllow) { if (RoleInfoService.SetRoleActionInfo(actionid, roleid, isAllow)) { return(Content("add")); } else { return(Content("error")); } } else { if (RoleInfoService.SetRoleActionInfo(actionid, roleid, isAllow)) { return(Content("remove")); } else { return(Content("error")); } } }
/// <summary> /// 完成角色权限的分配 /// </summary> /// <returns></returns> public ActionResult SetRoleActionInfo() { int roleId = int.Parse(Request["roleId"]); string[] allKeys = Request.Form.AllKeys; List <int> list = new List <int>(); foreach (string key in allKeys) { if (key.StartsWith("cba_")) { list.Add(Convert.ToInt32(key.Replace("cba_", ""))); } } return(Content(RoleInfoService.SetRoleActionInfo(roleId, list) ? "ok" : "no")); }
/// <summary> /// 完成角色权限的分配 /// </summary> /// <returns></returns> public ActionResult SetRoleAction() { int roleId = int.Parse(Request["roleId"]); //获取角色编号 string[] allKeys = Request.Form.AllKeys; //获取所有表单元素name属性的值。 List <int> list = new List <int>(); string markString = "cba_"; foreach (string key in allKeys) { if (key.StartsWith(markString)) { string k = key.Replace(markString, ""); list.Add(Convert.ToInt32(k)); } } bool isOK = RoleInfoService.SetRoleActionInfo(roleId, list); ResultCodeEnum resultCodeEnum = isOK ? ResultCodeEnum.Success : ResultCodeEnum.Failure; ResultModel <string> resultModel = new ResultModel <string>(resultCodeEnum); return(Json(resultModel)); }
public ActionResult SetRoleAction() { int roleId = int.Parse(Request["roleId"]); //获取角色编号 string[] allKeys = Request.Form.AllKeys; //获取所有表单元素name属性的值。 List <int> list = new List <int>(); foreach (string key in allKeys) { if (key.StartsWith("cba_")) { string k = key.Replace("cba_", ""); list.Add(Convert.ToInt32(k)); } } if (RoleInfoService.SetRoleActionInfo(roleId, list)) { return(Content("ok")); } else { return(Content("no")); } }