Exemple #1
0
        /// <summary>
        /// 删除用户根据主键
        /// </summary>
        /// <param name="roleId"></param>
        /// <param name="isLogicalDelete">是否逻辑删除</param>
        /// <returns></returns>
        public bool DeleteUsersByUsersId(int userId, bool isLogicalDelete = false)
        {
            UsersManager UsersManager = new UsersManager();

            RoleOp roleOp = new RoleOp();

            // 删除人和角色关系
            roleOp.DeleteRoleRefByUserId(userId);


            DepartmentOp departmentOp = new DepartmentOp();

            //部门中移除该人
            departmentOp.DeleteUserForDepartment(userId);

            return(ReomveUserFormDb(userId, isLogicalDelete, UsersManager));
        }
Exemple #2
0
        /// <summary>
        /// 根据主键批量删除用户
        /// </summary>
        /// <param name="userIds">用户id</param>
        /// <param name="isLogicalDelete">是否逻辑删除</param>
        /// <returns></returns>
        public bool DeleteUsers(List <int> userIds, bool isLogicalDelete)
        {
            bool           result       = true;
            UsersManager   UsersManager = new UsersManager();
            RoleOp         roleOp       = new RoleOp();
            List <dynamic> ids          = new List <dynamic>();
            DepartmentOp   departmentOp = new DepartmentOp();

            foreach (int id in userIds)
            {
                // 删除人和角色关系
                result = result && roleOp.DeleteRoleRefByUserId(id);
                ///人和部门
                result = result && departmentOp.DeleteUserForDepartment(id);
                //删除自己
                result = result && ReomveUserFormDb(id, isLogicalDelete, UsersManager);
            }
            return(result);
        }