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

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

                // split upgrade up
                var targetOfferId     = upgradeOfferSelected.Split("|".ToCharArray())[0];
                var targetUpgradeType = upgradeOfferSelected.Split("|".ToCharArray())[1];

                // upgrade the subscription
                await MySubscriptionRepository.UpgradeSubscrption(customerId, subscriptionId, targetOfferId, targetUpgradeType);

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