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"); }
public async Task<ViewResult> ChangeSubscription() { var currentSubscription = (await SubscriptionsFacade.UserActiveSubscriptionsAsync(User.Identity.GetUserId())).FirstOrDefault(); var model = new ChangeSubscriptionViewModel { SubscriptionPlans = await SubscriptionPlansFacade.GetAllAsync(), CurrentSubscription = currentSubscription != null ? currentSubscription.SubscriptionPlan.Id : string.Empty }; return View(model); }