Exemplo n.º 1
0
        public override void ExecuteCmdlet()
        {
            StoreClient = StoreClient ?? new StoreClient(
                CurrentSubscription.SubscriptionId,
                ServiceEndpoint,
                CurrentSubscription.Certificate,
                text => this.WriteDebug(text),
                Channel);
            CustomConfirmation = CustomConfirmation ?? new PowerShellCustomConfirmation(Host);
            WindowsAzureAddOn addon;

            if (StoreClient.TryGetAddOn(Name, out addon))
            {
                string message = StoreClient.GetConfirmationMessage(OperationType.Set, addon.AddOn, Plan);
                bool purchase = CustomConfirmation.ShouldProcess(Resources.SetAddOnConformation, message);

                if (purchase)
                {
                    StoreClient.UpdateAddOn(Name, Plan, PromotionCode);
                    WriteVerbose(string.Format(Resources.AddOnUpdatedMessage, Name));

                    if (PassThru.IsPresent)
                    {
                        WriteObject(true);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override void ExecuteCmdlet()
        {
            StoreClient = StoreClient ?? new StoreClient(
                CurrentSubscription.SubscriptionId,
                ServiceEndpoint,
                CurrentSubscription.Certificate,
                text => this.WriteDebug(text),
                Channel);
            WindowsAzureAddOn addon;
            CustomConfirmation = CustomConfirmation ?? new PowerShellCustomConfirmation(Host);

            if (!StoreClient.TryGetAddOn(Name, out addon))
            {
                string message = StoreClient.GetConfirmationMessage(OperationType.New, AddOn, Plan);
                bool purchase = CustomConfirmation.ShouldProcess(Resources.NewAddOnConformation, message);

                if (purchase)
                {
                    StoreClient.NewAddOn(Name, AddOn, Plan, Location, PromotionCode);
                    WriteVerbose(string.Format(Resources.AddOnCreatedMessage, Name));
                    WriteObject(true);
                }
            }
            else
            {
                throw new Exception(string.Format(Resources.AddOnNameAlreadyUsed, Name));
            }
        }