Exemple #1
0
        /// <summary>
        /// Executes the operations associated with the cmdlet.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            IValidator <Address> validator;
            LegalBusinessProfile profile;

            if (ShouldProcess(Resources.SetPartnerLegalProfileWhatIf))
            {
                profile = Partner.Profiles.LegalBusinessProfile.GetAsync().GetAwaiter().GetResult();

                profile.Address.AddressLine1   = UpdateValue(AddressLine1, profile.Address.AddressLine1);
                profile.Address.AddressLine2   = UpdateValue(AddressLine2, profile.Address.AddressLine2);
                profile.Address.City           = UpdateValue(City, profile.Address.City);
                profile.Address.Country        = UpdateValue(Country, profile.Address.Country);
                profile.Address.PostalCode     = UpdateValue(PostalCode, profile.Address.PostalCode);
                profile.Address.Region         = UpdateValue(Region, profile.Address.Region);
                profile.Address.State          = UpdateValue(State, profile.Address.State);
                profile.CompanyApproverAddress = profile.Address;
                profile.CompanyApproverEmail   = UpdateValue(EmailAddress, profile.CompanyApproverEmail);

                if (!DisableValidation.ToBool())
                {
                    validator = new AddressValidator(Partner);

                    if (!validator.IsValid(profile.Address, d => WriteDebug(d)))
                    {
                        throw new PSInvalidOperationException("The specified address is invalid. Please verify the address and try again.");
                    }
                }

                profile = Partner.Profiles.LegalBusinessProfile.UpdateAsync(profile).GetAwaiter().GetResult();

                WriteObject(new PSLegalBusinessProfile(profile));
            }
        }
        /// <summary>
        /// Executes the operations associated with the cmdlet.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            Scheduler.RunTask(async() =>
            {
                if (ShouldProcess(Resources.SetPartnerLegalProfileWhatIf))
                {
                    IPartner partner             = await PartnerSession.Instance.ClientFactory.CreatePartnerOperationsAsync(CorrelationId, CancellationToken).ConfigureAwait(false);
                    LegalBusinessProfile profile = await partner.Profiles.LegalBusinessProfile.GetAsync(VettingVersion.Current, CancellationToken).ConfigureAwait(false);

                    profile.Address.AddressLine1   = UpdateValue(AddressLine1, profile.Address.AddressLine1);
                    profile.Address.AddressLine2   = UpdateValue(AddressLine2, profile.Address.AddressLine2);
                    profile.Address.City           = UpdateValue(City, profile.Address.City);
                    profile.Address.Country        = UpdateValue(Country, profile.Address.Country);
                    profile.Address.PostalCode     = UpdateValue(PostalCode, profile.Address.PostalCode);
                    profile.Address.Region         = UpdateValue(Region, profile.Address.Region);
                    profile.Address.State          = UpdateValue(State, profile.Address.State);
                    profile.CompanyApproverAddress = profile.Address;
                    profile.CompanyApproverEmail   = UpdateValue(EmailAddress, profile.CompanyApproverEmail);

                    if (!DisableValidation.ToBool())
                    {
                        IValidator <Address> validator = new AddressValidator(partner);

                        if (!await validator.IsValidAsync(profile.Address, CancellationToken).ConfigureAwait(false))
                        {
                            throw new PSInvalidOperationException("The specified address is invalid. Please verify the address and try again.");
                        }
                    }

                    profile = await partner.Profiles.LegalBusinessProfile.UpdateAsync(profile, CancellationToken).ConfigureAwait(false);

                    WriteObject(new PSLegalBusinessProfile(profile));
                }
            }, true);
        }
        /// <summary>
        /// Executes the operations associated with the cmdlet.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            Scheduler.RunTask(async() =>
            {
                IPartner partner = await PartnerSession.Instance.ClientFactory.CreatePartnerOperationsAsync(CorrelationId, CancellationToken).ConfigureAwait(false);

                BillingProfile profile;
                IValidator <Address> validator;

                if (ShouldProcess("Updates the partner's billing profile"))
                {
                    profile = await partner.Profiles.BillingProfile.GetAsync(CancellationToken).ConfigureAwait(false);

                    profile.Address.AddressLine1 = UpdateValue(AddressLine1, profile.Address.AddressLine1);
                    profile.Address.AddressLine2 = UpdateValue(AddressLine2, profile.Address.AddressLine2);
                    profile.Address.City         = UpdateValue(City, profile.Address.City);
                    profile.Address.PostalCode   = UpdateValue(PostalCode, profile.Address.PostalCode);
                    profile.Address.Region       = UpdateValue(Region, profile.Address.Region);
                    profile.Address.State        = UpdateValue(State, profile.Address.State);

                    profile.PrimaryContact.Email       = UpdateValue(EmailAddress, profile.PrimaryContact.Email);
                    profile.PrimaryContact.FirstName   = UpdateValue(FirstName, profile.PrimaryContact.FirstName);
                    profile.PrimaryContact.LastName    = UpdateValue(LastName, profile.PrimaryContact.LastName);
                    profile.PrimaryContact.PhoneNumber = UpdateValue(PhoneNumber, profile.PrimaryContact.PhoneNumber);

                    profile.PurchaseOrderNumber = UpdateValue(PurchaseOrderNumber, profile.PurchaseOrderNumber);
                    profile.TaxId = UpdateValue(TaxId, profile.TaxId);


                    if (!DisableValidation.ToBool())
                    {
                        validator = new AddressValidator(partner);

                        if (!await validator.IsValidAsync(profile.Address, CancellationToken).ConfigureAwait(false))
                        {
                            throw new PSInvalidOperationException("The specified address is invalid. Please verify the address and try again.");
                        }
                    }

                    await partner.Profiles.BillingProfile.UpdateAsync(profile, CancellationToken).ConfigureAwait(false);

                    WriteObject(new PSBillingProfile(profile));
                }
            }, true);
        }
Exemple #4
0
        /// <summary>
        /// Executes the operations associated with the cmdlet.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            Customer             customer;
            IValidator <Address> validator;
            string customerId;

            customerId = (InputObject == null) ? CustomerId : InputObject.CustomerId;

            if (ShouldProcess(string.Format(CultureInfo.CurrentCulture, Resources.SetPartnerCustomerWhatIf, customerId)))
            {
                if (InputObject == null && string.IsNullOrEmpty(CustomerId))
                {
                    throw new PSInvalidOperationException(Resources.InvalidSetCustomerIdentifierException);
                }

                customer = Partner.Customers[customerId].GetAsync().ConfigureAwait(false).GetAwaiter().GetResult();

                customer.BillingProfile.DefaultAddress.AddressLine1 = UpdateValue(BillingAddressLine1, customer.BillingProfile.DefaultAddress.AddressLine1);
                customer.BillingProfile.DefaultAddress.AddressLine2 = UpdateValue(BillingAddressLine2, customer.BillingProfile.DefaultAddress.AddressLine2);
                customer.BillingProfile.DefaultAddress.City         = UpdateValue(BillingAddressCity, customer.BillingProfile.DefaultAddress.City);
                customer.BillingProfile.DefaultAddress.Country      = UpdateValue(BillingAddressCountry, customer.BillingProfile.DefaultAddress.Country);
                customer.BillingProfile.DefaultAddress.PhoneNumber  = UpdateValue(BillingAddressPhoneNumber, customer.BillingProfile.DefaultAddress.PhoneNumber);
                customer.BillingProfile.DefaultAddress.PostalCode   = UpdateValue(BillingAddressPostalCode, customer.BillingProfile.DefaultAddress.PostalCode);
                customer.BillingProfile.DefaultAddress.Region       = UpdateValue(BillingAddressRegion, customer.BillingProfile.DefaultAddress.Region);
                customer.BillingProfile.DefaultAddress.State        = UpdateValue(BillingAddressState, customer.BillingProfile.DefaultAddress.State);
                customer.BillingProfile.CompanyName = UpdateValue(Name, customer.BillingProfile.CompanyName);
                customer.BillingProfile.Email       = UpdateValue(Email, customer.BillingProfile.Email);


                if (!DisableValidation.ToBool())
                {
                    validator = new AddressValidator(Partner);

                    if (!validator.IsValid(customer.BillingProfile.DefaultAddress, d => WriteDebug(d)))
                    {
                        throw new PartnerException("The address for the customer is not valid.");
                    }
                }

                Partner.Customers[customerId].Profiles.Billing.UpdateAsync(customer.BillingProfile).GetAwaiter().GetResult();

                WriteObject(new PSCustomer(customer));
            }
        }
Exemple #5
0
        /// <summary>
        /// Executes the operations associated with the cmdlet.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            string customerId = (InputObject == null) ? CustomerId : InputObject.CustomerId;

            Scheduler.RunTask(async() =>
            {
                if (ShouldProcess(string.Format(CultureInfo.CurrentCulture, Resources.SetPartnerCustomerWhatIf, customerId)))
                {
                    IPartner partner = await PartnerSession.Instance.ClientFactory.CreatePartnerOperationsAsync(CorrelationId, CancellationToken).ConfigureAwait(false);
                    Customer customer;
                    IValidator <Address> validator;

                    customer = await partner.Customers[customerId].GetAsync(CancellationToken).ConfigureAwait(false);

                    customer.BillingProfile.DefaultAddress.AddressLine1 = UpdateValue(BillingAddressLine1, customer.BillingProfile.DefaultAddress.AddressLine1);
                    customer.BillingProfile.DefaultAddress.AddressLine2 = UpdateValue(BillingAddressLine2, customer.BillingProfile.DefaultAddress.AddressLine2);
                    customer.BillingProfile.DefaultAddress.City         = UpdateValue(BillingAddressCity, customer.BillingProfile.DefaultAddress.City);
                    customer.BillingProfile.DefaultAddress.Country      = UpdateValue(BillingAddressCountry, customer.BillingProfile.DefaultAddress.Country);
                    customer.BillingProfile.DefaultAddress.PhoneNumber  = UpdateValue(BillingAddressPhoneNumber, customer.BillingProfile.DefaultAddress.PhoneNumber);
                    customer.BillingProfile.DefaultAddress.PostalCode   = UpdateValue(BillingAddressPostalCode, customer.BillingProfile.DefaultAddress.PostalCode);
                    customer.BillingProfile.DefaultAddress.Region       = UpdateValue(BillingAddressRegion, customer.BillingProfile.DefaultAddress.Region);
                    customer.BillingProfile.DefaultAddress.State        = UpdateValue(BillingAddressState, customer.BillingProfile.DefaultAddress.State);
                    customer.BillingProfile.CompanyName = UpdateValue(Name, customer.BillingProfile.CompanyName);
                    customer.BillingProfile.Email       = UpdateValue(Email, customer.BillingProfile.Email);


                    if (!DisableValidation.ToBool())
                    {
                        validator = new AddressValidator(partner);

                        if (!await validator.IsValidAsync(customer.BillingProfile.DefaultAddress, CancellationToken).ConfigureAwait(false))
                        {
                            throw new PartnerPowerShellException("The address for the customer is not valid.", PartnerPowerShellErrorCategory.Validation);
                        }
                    }

                    await partner.Customers[customerId].Profiles.Billing.UpdateAsync(customer.BillingProfile, CancellationToken).ConfigureAwait(false);

                    WriteObject(new PSCustomer(customer));
                }
            }, true);
        }
Exemple #6
0
        /// <summary>
        /// Executes the operations associated with the cmdlet.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            BillingProfile       profile;
            IValidator <Address> validator;

            if (ShouldProcess("Updates the partner's billing profile"))
            {
                profile = Partner.Profiles.BillingProfile.GetAsync().GetAwaiter().GetResult();

                profile.Address.AddressLine1 = UpdateValue(AddressLine1, profile.Address.AddressLine1);
                profile.Address.AddressLine2 = UpdateValue(AddressLine2, profile.Address.AddressLine2);
                profile.Address.City         = UpdateValue(City, profile.Address.City);
                profile.Address.PostalCode   = UpdateValue(PostalCode, profile.Address.PostalCode);
                profile.Address.Region       = UpdateValue(Region, profile.Address.Region);
                profile.Address.State        = UpdateValue(State, profile.Address.State);

                profile.PrimaryContact.Email       = UpdateValue(EmailAddress, profile.PrimaryContact.Email);
                profile.PrimaryContact.FirstName   = UpdateValue(FirstName, profile.PrimaryContact.FirstName);
                profile.PrimaryContact.LastName    = UpdateValue(LastName, profile.PrimaryContact.LastName);
                profile.PrimaryContact.PhoneNumber = UpdateValue(PhoneNumber, profile.PrimaryContact.PhoneNumber);

                profile.PurchaseOrderNumber = UpdateValue(PurchaseOrderNumber, profile.PurchaseOrderNumber);
                profile.TaxId = UpdateValue(TaxId, profile.TaxId);


                if (!DisableValidation.ToBool())
                {
                    validator = new AddressValidator(Partner);

                    if (!validator.IsValid(profile.Address, d => WriteDebug(d)))
                    {
                        throw new PSInvalidOperationException("The specified address is invalid. Please verify the address and try again.");
                    }
                }

                Partner.Profiles.BillingProfile.UpdateAsync(profile).GetAwaiter().GetResult();

                WriteObject(new PSBillingProfile(profile));
            }
        }
        /// <summary>
        /// Executes the operations associated with the cmdlet.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            Scheduler.RunTask(async() =>
            {
                if (ShouldProcess("Updates the partner's organization profile"))
                {
                    IPartner partner = await PartnerSession.Instance.ClientFactory.CreatePartnerOperationsAsync(CorrelationId, CancellationToken).ConfigureAwait(false);

                    OrganizationProfile profile = await partner.Profiles.OrganizationProfile.GetAsync(CancellationToken).ConfigureAwait(false);

                    profile.CompanyName = UpdateValue(CompanyName, profile.CompanyName);
                    profile.Email       = UpdateValue(Email, profile.Email);
                    profile.Language    = UpdateValue(Language, profile.Language);
                    profile.Culture     = UpdateValue(Culture, profile.Culture);

                    profile.DefaultAddress.AddressLine1 = UpdateValue(AddressLine1, profile.DefaultAddress.AddressLine1);
                    profile.DefaultAddress.AddressLine2 = UpdateValue(AddressLine2, profile.DefaultAddress.AddressLine2);
                    profile.DefaultAddress.City         = UpdateValue(City, profile.DefaultAddress.City);
                    profile.DefaultAddress.Country      = UpdateValue(Country, profile.DefaultAddress.Country);
                    profile.DefaultAddress.PostalCode   = UpdateValue(PostalCode, profile.DefaultAddress.PostalCode);
                    profile.DefaultAddress.State        = UpdateValue(State, profile.DefaultAddress.State);
                    profile.DefaultAddress.FirstName    = UpdateValue(FirstName, profile.DefaultAddress.FirstName);
                    profile.DefaultAddress.LastName     = UpdateValue(LastName, profile.DefaultAddress.LastName);
                    profile.DefaultAddress.PhoneNumber  = UpdateValue(PhoneNumber, profile.DefaultAddress.PhoneNumber);

                    if (!DisableValidation.ToBool())
                    {
                        IValidator <Address> validator = new AddressValidator(partner);

                        if (!await validator.IsValidAsync(profile.DefaultAddress, CancellationToken).ConfigureAwait(false))
                        {
                            throw new PSInvalidOperationException("The specified address is invalid. Please verify the address and try again.");
                        }
                    }

                    profile = await partner.Profiles.OrganizationProfile.UpdateAsync(profile, CancellationToken).ConfigureAwait(false);
                    WriteObject(new PSOrganizationProfile(profile));
                }
            }, true);
        }
Exemple #8
0
        /// <summary>
        /// Executes the operations associated with the cmdlet.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            OrganizationProfile  profile;
            IValidator <Address> validator;

            if (ShouldProcess("Updates the partner's organization profile"))
            {
                profile = Partner.Profiles.OrganizationProfile.GetAsync().ConfigureAwait(false).GetAwaiter().GetResult();

                profile.CompanyName = UpdateValue(CompanyName, profile.CompanyName);
                profile.Email       = UpdateValue(Email, profile.Email);
                profile.Language    = UpdateValue(Language, profile.Language);
                profile.Culture     = UpdateValue(Culture, profile.Culture);

                profile.DefaultAddress.AddressLine1 = UpdateValue(AddressLine1, profile.DefaultAddress.AddressLine1);
                profile.DefaultAddress.AddressLine2 = UpdateValue(AddressLine2, profile.DefaultAddress.AddressLine2);
                profile.DefaultAddress.City         = UpdateValue(City, profile.DefaultAddress.City);
                profile.DefaultAddress.Country      = UpdateValue(Country, profile.DefaultAddress.Country);
                profile.DefaultAddress.PostalCode   = UpdateValue(PostalCode, profile.DefaultAddress.PostalCode);
                profile.DefaultAddress.State        = UpdateValue(State, profile.DefaultAddress.State);
                profile.DefaultAddress.FirstName    = UpdateValue(FirstName, profile.DefaultAddress.FirstName);
                profile.DefaultAddress.LastName     = UpdateValue(LastName, profile.DefaultAddress.LastName);
                profile.DefaultAddress.PhoneNumber  = UpdateValue(PhoneNumber, profile.DefaultAddress.PhoneNumber);

                if (!DisableValidation.ToBool())
                {
                    validator = new AddressValidator(Partner);

                    if (!validator.IsValid(profile.DefaultAddress, d => WriteDebug(d)))
                    {
                        throw new PSInvalidOperationException("The specified address is invalid. Please verify the address and try again.");
                    }
                }

                profile = Partner.Profiles.OrganizationProfile.UpdateAsync(profile).GetAwaiter().GetResult();
                WriteObject(new PSOrganizationProfile(profile));
            }
        }