예제 #1
0
파일: roleEx.cs 프로젝트: xxzzjj222/Athena
        /// <summary>
        /// 根据角色id删除角色及该角色对应的动作和资源
        /// </summary>
        /// <param name="id">用户id</param>
        /// <returns></returns>
        public bool deleteroleAR(int id)
        {
            roleActionEx    rae             = new roleActionEx();
            roleResourceEx  rre             = new roleResourceEx();
            List <action>   curactionList   = rae.getRoleAllAction(id, "");
            List <resource> curresourceList = rre.getRoleAllResource(id, "");
            role            r     = getRole(id);
            bool            rflag = db.Delete <role>(r);

            if (curactionList.Count == 0 && curresourceList.Count == 0)
            {
                return(rflag);
            }
            else
            {
                bool raflag = true;
                bool rrflag = true;
                foreach (var item in curactionList)
                {
                    role_action ra = rae.getRoleAction(id, item.id);
                    raflag = db.Delete <role_action>(ra);
                }
                foreach (var item in curresourceList)
                {
                    role_resource rr = rre.getRoleResourceById(id, item.id);
                    rrflag = db.Delete <role_resource>(rr);
                }
                return(rflag & raflag & rrflag);
            }
        }
예제 #2
0
파일: roleEx.cs 프로젝트: xxzzjj222/Athena
 /// <summary>
 /// 动作授权
 /// </summary>
 /// <param name="actionpermissionIds"></param>
 /// <param name="keyValue"></param>
 public void actionAuthority(string actionpermissionIds, int keyValue)
 {
     if (!string.IsNullOrEmpty(actionpermissionIds))
     {
         string[]      ids          = actionpermissionIds.Split(',');
         IroleActionEx roleactionex = new roleActionEx();
         IactionEx     actionex     = new actionEx();
         for (int i = 0; i < ids.Length; i++)
         {
             if (actionex.getEntityById(Convert.ToInt32(ids[i])).controlername != "0")
             {
                 roleactionex.addRoleAction(Convert.ToInt32(ids[i]), keyValue);
             }
         }
     }
 }