private static void PatchOrganization(ExtensionAttributeEnterpriseUser2 extension, PatchOperation2 operation)
        {
            OperationValue value = operation.Value.SingleOrDefault();

            if (OperationName.Remove == operation.Name)
            {
                if ((null == value) || string.Equals(extension.Organization, value.Value, StringComparison.OrdinalIgnoreCase))
                {
                    value = null;
                }
                else
                {
                    return;
                }
            }

            if (null == value)
            {
                extension.Organization = null;
            }
            else
            {
                extension.Organization = value.Value;
            }
        }
        private static void PatchEnterpriseExtension(this Core2EnterpriseUser user, PatchOperation2 operation)
        {
            if (null == operation)
            {
                return;
            }

            if (null == operation.Path || string.IsNullOrWhiteSpace(operation.Path.AttributePath))
            {
                return;
            }

            ExtensionAttributeEnterpriseUser2 extension = user.EnterpriseExtension;

            switch (operation.Path.AttributePath)
            {
            case AttributeNames.CostCenter:
                Core2EnterpriseUserExtensions.PatchCostCenter(extension, operation);
                break;

            case AttributeNames.Department:
                Core2EnterpriseUserExtensions.PatchDepartment(extension, operation);
                break;

            case AttributeNames.Division:
                Core2EnterpriseUserExtensions.PatchDivision(extension, operation);
                break;

            case AttributeNames.EmployeeNumber:
                Core2EnterpriseUserExtensions.PatchEmployeeNumber(extension, operation);
                break;

            case AttributeNames.Manager:
                Core2EnterpriseUserExtensions.PatchManager(extension, operation);
                break;

            case AttributeNames.Organization:
                Core2EnterpriseUserExtensions.PatchOrganization(extension, operation);
                break;
            }
        }
Ejemplo n.º 3
0
        public SampleProvider()
        {
            this.sampleElectronicMailAddressHome =
                new ElectronicMailAddress
            {
                ItemType = ElectronicMailAddress.Home,
                Value    = SampleProvider.ElectronicMailAddressHome
            };

            this.sampleElectronicMailAddressWork =
                new ElectronicMailAddress
            {
                ItemType = ElectronicMailAddressWork,
                Primary  = true,
                Value    = SampleProvider.ElectronicMailAddressWork
            };

            this.sampleElectronicMailAddresses =
                new ElectronicMailAddress[]
            {
                this.sampleElectronicMailAddressHome,
                this.sampleElectronicMailAddressWork
            };

            this.sampleManager =
                new Manager()
            {
                Value = SampleProvider.ManagerIdentifier,
            };

            this.sampleName =
                new Name()
            {
                FamilyName      = SampleProvider.NameFamily,
                Formatted       = SampleProvider.NameFormatted,
                GivenName       = SampleProvider.NameGiven,
                HonorificPrefix = SampleProvider.NameHonorificPrefix,
                HonorificSuffix = SampleProvider.NameHonorificSuffix
            };

            this.sampleOperationValue =
                new OperationValue()
            {
                Value = SampleProvider.IdentifierUser
            };

            this.sampleOperation = this.ConstructOperation();

            this.samplePatch = this.ConstructPatch();

            this.sampleUser =
                new Core2EnterpriseUser()
            {
                Active = true,
                ElectronicMailAddresses = this.sampleElectronicMailAddresses,
                ExternalIdentifier      = SampleProvider.IdentifierExternal,
                Identifier = SampleProvider.IdentifierUser,
                Name       = this.sampleName,
                UserName   = SampleProvider.NameUser
            };

            ExtensionAttributeEnterpriseUser2 enterpriseExtensionAttributeEnterpriseUser2 =
                new ExtensionAttributeEnterpriseUser2()
            {
                CostCenter     = SampleProvider.ExtensionAttributeEnterpriseUserCostCenter,
                Department     = SampleProvider.ExtensionAttributeEnterpriseUserDepartment,
                Division       = SampleProvider.ExtensionAttributeEnterpriseUserDivision,
                EmployeeNumber = SampleProvider.ExtensionAttributeEnterpriseUserEmployeeNumber,
                Manager        = this.sampleManager,
                Organization   = SampleProvider.ExtensionAttributeEnterpriseUserOrganization
            };

            this.SampleUser.EnterpriseExtension = enterpriseExtensionAttributeEnterpriseUser2;

            this.sampleGroup =
                new Core2Group()
            {
                DisplayName = SampleProvider.GroupName,
            };
        }