コード例 #1
0
        public User SaveUser(User user, bool rolePermission, bool bRole)
        {
            int userId = manager.SaveUserBasicInfo(user.UserId, user.UserName, user.EmpName, user.Password, user.Mobile, user.EmployeeId, user.IsActive);

            user.UserId = userId;
            if (bRole)
            {
                manager.DeleteUserRoleByRoleId(userId);
                for (int i = 0; i < user.UserRoleCount; i++)
                {
                    Role role = user[i, "notUse"];
                    manager.SaveUserRole(userId, role.RoleId);
                }
            }
            if (rolePermission)
            {
                for (int i = 0; i < user.UserRoleCount; i++)
                {
                    Role userRolePermission = user[i, "notUser"];
                    manager.DeleteUserRolePermissionByUserRoleId(userId, userRolePermission.RoleId);
                }

                for (int i = 0; i < user.UserRolePermissionCount; i++)
                {
                    UserRolePermission userRolePermission = user[i];

                    manager.SaveUserRolePermission(user.UserId, userRolePermission.Permission.PermissionId,
                                                   userRolePermission.Role.RoleId);
                }
            }
            return(user);
        }