/// <summary> /// Reverts the subscription renewal. /// </summary> /// <returns>A task.</returns> public async Task RollbackAsync() { if (Result != null) { try { // restore the original subscription state await SubscriptionOperations.PatchAsync(existingSubscription).ConfigureAwait(false); } catch (Exception rollbackProblem) { if (rollbackProblem.IsFatal()) { throw; } Trace.TraceError( "RenewSubscription.RollbackAsync failed: {0}, Customer ID: {1}, Subscription ID: {2}, Subscription: {3}", rollbackProblem, SubscriptionOperations.Context.Item1, SubscriptionOperations.Context.Item2, existingSubscription); // TODO: Notify the system integrity recovery component } } Result = null; }
/// <summary> /// Reverts the seat change. /// </summary> /// <returns>A task.</returns> public async Task RollbackAsync() { if (Result != null) { try { // restore the original seat count for the subscription Result.Quantity = originalSeatCount; await SubscriptionOperations.PatchAsync(Result).ConfigureAwait(false); } catch (Exception subscriptionUpdateProblem) { if (subscriptionUpdateProblem.IsFatal()) { throw; } Trace.TraceError("PurchaseExtraSeats.RollbackAsync failed: {0}, ID: {1}, Quantity: {2}.", subscriptionUpdateProblem, this.Result.Id, this.Result.Quantity); // TODO: Notify the system integrity recovery component } } this.Result = null; }
/// <summary> /// Purchases additional seats for the subscription. /// </summary> /// <returns>A task.</returns> public async Task ExecuteAsync() { try { // activate the subscription (in case it was suspended) Result = await SubscriptionOperations.PatchAsync(new Subscription() { Status = SubscriptionStatus.Active }).ConfigureAwait(false); } catch (PartnerException subscriptionUpdateProblem) { string exceptionMessage = string.Format( CultureInfo.InvariantCulture, Resources.RenewSubscriptionFailedMessage, subscriptionUpdateProblem, existingSubscription.Id); if (subscriptionUpdateProblem.ErrorCategory == PartnerErrorCategory.NotFound) { throw new PartnerDomainException(ErrorCode.SubscriptionNotFound, exceptionMessage, subscriptionUpdateProblem); } else { throw new PartnerDomainException(ErrorCode.SubscriptionUpdateFailure, exceptionMessage, subscriptionUpdateProblem); } } }
/// <summary> /// Purchases additional seats for the subscription. /// </summary> /// <returns>A task.</returns> public async Task ExecuteAsync() { try { Subscription partnerCenterSubscription = await SubscriptionOperations.GetAsync().ConfigureAwait(false); originalSeatCount = partnerCenterSubscription.Quantity; partnerCenterSubscription.Quantity += SeatsToPurchase; Result = await SubscriptionOperations.PatchAsync(partnerCenterSubscription).ConfigureAwait(false); } catch (PartnerException subscriptionUpdateProblem) { if (subscriptionUpdateProblem.ErrorCategory == PartnerErrorCategory.NotFound) { throw new PartnerDomainException(ErrorCode.SubscriptionNotFound, "PurchaseExtraSeats.ExecuteAsync() Failed", subscriptionUpdateProblem); } else { throw new PartnerDomainException(ErrorCode.SubscriptionUpdateFailure, "PurchaseExtraSeats.ExecuteAsync() Failed", subscriptionUpdateProblem); } } }