コード例 #1
0
        public async Task <ActionResult> AddLicense(string customerId, string subscriptionId, string licensesToAdd)
        {
            // if no ids provided, redirect to list
            if (string.IsNullOrEmpty(customerId) || string.IsNullOrEmpty(subscriptionId) || string.IsNullOrEmpty(licensesToAdd))
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                // get customer
                var customer = await MyCustomerRepository.GetCustomer(customerId);

                // get subscription
                var subscription = await MySubscriptionRepository.GetSubscription(customerId, subscriptionId);

                // update quantity and save
                subscription.Quantity += Convert.ToInt16(licensesToAdd);
                await MySubscriptionRepository.UpdateSubscription(customerId, subscription);


                return(RedirectToAction("Index"));
            }
        }