public async Task <PartialViewResult> Create(NewSubscriptionModel model)
        {
            IAggregatePartner  operations;
            Order              newOrder;
            SubscriptionsModel subscriptionsModel;

            try
            {
                operations = await new SdkContext().GetPartnerOperationsAysnc();
                newOrder   = new Order()
                {
                    LineItems           = model.LineItems,
                    ReferenceCustomerId = model.CustomerId
                };

                newOrder = await operations.Customers.ById(model.CustomerId).Orders.CreateAsync(newOrder);

                subscriptionsModel = await GetSubscriptionsAsync(model.CustomerId);

                return(PartialView("List", subscriptionsModel));
            }
            finally
            {
                newOrder = null;
            }
        }
        public PartialViewResult Create(string customerId)
        {
            customerId.AssertNotEmpty(nameof(customerId));

            NewSubscriptionModel newSubscriptionModel = new NewSubscriptionModel()
            {
                CustomerId = customerId
            };

            return(this.PartialView(newSubscriptionModel));
        }
        public PartialViewResult Create(string customerId)
        {
            if (string.IsNullOrEmpty(customerId))
            {
                throw new ArgumentNullException(nameof(customerId));
            }

            NewSubscriptionModel newSubscriptionModel = new NewSubscriptionModel()
            {
                CustomerId = customerId
            };

            return(PartialView(newSubscriptionModel));
        }
        public async Task <PartialViewResult> Create(NewSubscriptionModel model)
        {
            Order newOrder;
            SubscriptionsModel subscriptionsModel;

            try
            {
                newOrder = new Order()
                {
                    LineItems           = model.LineItems,
                    ReferenceCustomerId = model.CustomerId
                };

                newOrder = await this.Service.PartnerOperations.CreateOrderAsync(model.CustomerId, newOrder);

                subscriptionsModel = await this.GetSubscriptionsAsync(model.CustomerId);

                return(this.PartialView("List", subscriptionsModel));
            }
            finally
            {
                newOrder = null;
            }
        }
        public async Task <PartialViewResult> Create(NewSubscriptionModel model)
        {
            Order newOrder;
            SubscriptionsModel subscriptionsModel;

            try
            {
                newOrder = new Order()
                {
                    LineItems           = model.LineItems,
                    ReferenceCustomerId = model.CustomerId
                };

                newOrder = await Provider.PartnerOperations.CreateOrderAsync(model.CustomerId, newOrder).ConfigureAwait(false);

                subscriptionsModel = await GetSubscriptionsAsync(model.CustomerId).ConfigureAwait(false);

                return(PartialView("List", subscriptionsModel));
            }
            finally
            {
                newOrder = null;
            }
        }
Пример #6
0
 /// <summary>
 /// Creates a new Subscription and returns it.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='newItem'>
 /// Definition of how the Subscription will be created.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <SubscriptionModel> CreateAsync(this ISubscriptions operations, NewSubscriptionModel newItem, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateWithHttpMessagesAsync(newItem, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Пример #7
0
 /// <summary>
 /// Creates a new Subscription and returns it.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='newItem'>
 /// Definition of how the Subscription will be created.
 /// </param>
 public static SubscriptionModel Create(this ISubscriptions operations, NewSubscriptionModel newItem)
 {
     return(Task.Factory.StartNew(s => ((ISubscriptions)s).CreateAsync(newItem), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }