Ejemplo n.º 1
0
        private PatchRequest2 ConstructPatch()
        {
            PatchRequest2 result = new PatchRequest2();

            result.AddOperation(this.sampleOperation);
            return(result);
        }
        public static void Apply(this Core2EnterpriseUser user, PatchRequest2 patch)
        {
            if (null == user)
            {
                throw new ArgumentNullException(nameof(user));
            }

            if (null == patch)
            {
                return;
            }

            if (null == patch.Operations || !patch.Operations.Any())
            {
                return;
            }

            foreach (PatchOperation2Combined operation in patch.Operations)
            {
                PatchOperation2 operationInternal = new PatchOperation2()
                {
                    OperationName = operation.OperationName,
                    Path          = operation.Path
                };

                OperationValue[] values =
                    JsonConvert.DeserializeObject <OperationValue[]>(
                        operation.Value,
                        ProtocolConstants.JsonSettings.Value);

                if (values == null)
                {
                    string value =
                        JsonConvert.DeserializeObject <string>(operation.Value, ProtocolConstants.JsonSettings.Value);
                    OperationValue valueSingle = new OperationValue()
                    {
                        Value = value
                    };
                    operationInternal.AddValue(valueSingle);
                }
                else
                {
                    foreach (OperationValue value in values)
                    {
                        operationInternal.AddValue(value);
                    }
                }

                user.Apply(operationInternal);
            }
        }
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,
            };
        }