Changes to samples to exercise new properties of Transitions and Update Subscription (#82)
* Changes to samples to exercise new Transition and Update Subscription compound update changes. * move usings inside namespace
This commit is contained in:
Родитель
d41a8218ae
Коммит
b1625c9f54
|
@ -6,8 +6,8 @@
|
|||
|
||||
namespace Microsoft.Store.PartnerCenter.Samples.Subscriptions
|
||||
{
|
||||
using Microsoft.Store.PartnerCenter.Models.Subscriptions;
|
||||
using System.Linq;
|
||||
using Microsoft.Store.PartnerCenter.Models.Subscriptions;
|
||||
|
||||
/// <summary>
|
||||
/// A scenario that transitions a customer subscription to a higher sku.
|
||||
|
@ -59,16 +59,42 @@ namespace Microsoft.Store.PartnerCenter.Samples.Subscriptions
|
|||
}
|
||||
else
|
||||
{
|
||||
// the selected transition is eligible, go ahead and perform the transition
|
||||
this.Context.ConsoleHelper.StartProgress("Transtioning subscription");
|
||||
|
||||
var targetTransition = new Transition()
|
||||
{
|
||||
ToCatalogItemId = selectedEligibility.CatalogItemId,
|
||||
Quantity = selectedEligibility.Quantity,
|
||||
TransitionType = selectedEligibility.Eligibilities.FirstOrDefault(detail => detail.IsEligible == true).TransitionType
|
||||
};
|
||||
|
||||
string targetQuantity = this.Context.ConsoleHelper.ReadOptionalString("Enter a quantity to transition or leave blank to transition all existing seats");
|
||||
|
||||
targetTransition.Quantity = !string.IsNullOrWhiteSpace(targetQuantity) ? int.Parse(targetQuantity) : selectedEligibility.Quantity;
|
||||
|
||||
string updateToSubscriptionsId = this.Context.ConsoleHelper.ReadOptionalString("Would you like to transition into an existing subscription? [y/n]");
|
||||
|
||||
if (string.Equals(updateToSubscriptionsId, "y", System.StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
targetTransition.ToSubscriptionId = this.ObtainSubscriptionId(customerId, "Enter the ID of the subscription to set as target subscription for the transition (Must match same catalogItemId)");
|
||||
}
|
||||
else
|
||||
{
|
||||
string targetTermDuration = this.Context.ConsoleHelper.ReadOptionalString("Enter a new term duration to apply during the transition, leave blank to keep the same [example: P1Y, P1M]");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(targetTermDuration))
|
||||
{
|
||||
targetTransition.TermDuration = targetTermDuration;
|
||||
|
||||
string targetBillingCycle = this.Context.ConsoleHelper.ReadOptionalString("Enter a new billing cycle to apply during the transition, leave blank to keep the same [example: Annual or Monthly]");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(targetBillingCycle))
|
||||
{
|
||||
targetTransition.BillingCycle = targetBillingCycle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// the selected transition is eligible, go ahead and perform the transition
|
||||
this.Context.ConsoleHelper.StartProgress("Transtioning subscription");
|
||||
|
||||
var transitionResult = subscriptionOperations.Transitions.Create(targetTransition);
|
||||
this.Context.ConsoleHelper.StopProgress();
|
||||
this.Context.ConsoleHelper.WriteObject(transitionResult, "Transtion details");
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
namespace Microsoft.Store.PartnerCenter.Samples.Subscriptions
|
||||
{
|
||||
using System;
|
||||
using Microsoft.Store.PartnerCenter.Models.Offers;
|
||||
|
||||
/// <summary>
|
||||
/// A scenario that updates an existing customer subscription.
|
||||
/// </summary>
|
||||
|
@ -33,8 +36,26 @@ namespace Microsoft.Store.PartnerCenter.Samples.Subscriptions
|
|||
this.Context.ConsoleHelper.StopProgress();
|
||||
this.Context.ConsoleHelper.WriteObject(existingSubscription, "Existing subscription");
|
||||
|
||||
this.Context.ConsoleHelper.StartProgress("Incrementing subscription quantity");
|
||||
existingSubscription.Quantity++;
|
||||
string targetQuantity = this.Context.ConsoleHelper.ReadOptionalString("Enter target quantity or leave blank to keep quantity the same");
|
||||
if (!string.IsNullOrWhiteSpace(targetQuantity)) {
|
||||
existingSubscription.Quantity = int.Parse(targetQuantity);
|
||||
}
|
||||
|
||||
string targetTermDuration = this.Context.ConsoleHelper.ReadOptionalString("Enter a new term duration or leave blank to keep the same [example: P1Y, P1M]");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(targetTermDuration))
|
||||
{
|
||||
existingSubscription.TermDuration = targetTermDuration;
|
||||
|
||||
string targetBillingCycle = this.Context.ConsoleHelper.ReadOptionalString("Enter a new billing cycle or leave blank to keep the same [example: Annual or Monthly]");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(targetBillingCycle))
|
||||
{
|
||||
existingSubscription.BillingCycle = (BillingCycleType)Enum.Parse(typeof(BillingCycleType), targetBillingCycle, true);
|
||||
}
|
||||
}
|
||||
|
||||
this.Context.ConsoleHelper.StartProgress("Updating subscription");
|
||||
var updatedSubscription = partnerOperations.Customers.ById(customerId).Subscriptions.ById(subscriptionId).Patch(existingSubscription);
|
||||
this.Context.ConsoleHelper.StopProgress();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче