public async Task <ActionResult> ReActivateSubscription() { var currentSubscription = (await SubscriptionsFacade.UserActiveSubscriptionsAsync(User.Identity.GetUserId())).FirstOrDefault(); var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); if (currentSubscription != null && await SubscriptionsFacade.UpdateSubscriptionAsync(user.Id, user.StripeCustomerId, currentSubscription.SubscriptionPlanId)) { // TempData.Add("flash", new FlashSuccessViewModel("Your subscription plan has been re-activated.")); } else { // TempData.Add("flash", new FlashDangerViewModel("Ooops! There was a problem re-activating your subscription. Please, try again.")); } return(RedirectToAction("Index")); }
public async Task <ActionResult> ChangeSubscription(ChangeSubscriptionViewModel model) { if (ModelState.IsValid) { var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); await SubscriptionsFacade.UpdateSubscriptionAsync(user.Id, user.StripeCustomerId, model.NewPlan); // TempData.Add("flash", new FlashSuccessViewModel("Your subscription plan has been updated.")); } else { // TempData.Add("flash", new FlashSuccessViewModel("Sorry, there was an error updating your plan, try again or contact support.")); } return(RedirectToAction("Index")); }