public async Task <ActionResult> AddCreditCard(CreditCardViewModel model) { if (ModelState.IsValid) { var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); await CardService.AddAsync(user, model.CreditCard); // TempData.Add("flash", new FlashSuccessViewModel("Your credit card has been saved successfully.")); return(RedirectToAction("Index")); } return(View(model)); }
public async Task <ActionResult> ChangeCreditCard(CreditCardViewModel model) { var userId = User.Identity.GetUserId(); if (ModelState.IsValid && await CardService.CardBelongToUser(model.CreditCard.Id, userId)) { var user = await UserManager.FindByIdAsync(userId); await CardService.UpdateAsync(user, model.CreditCard); // TempData.Add("flash", new FlashSuccessViewModel("Your credit card has been updated successfully.")); return(RedirectToAction("Index")); } return(View(model)); }
public async Task <ActionResult> ChangeCreditCard(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var model = new CreditCardViewModel { CreditCard = await CardService.FindAsync(User.Identity.GetUserId(), id) }; // If the card doesn't exist or doesn't belong the logged in user if (model.CreditCard == null || model.CreditCard.SaasEcomUserId != User.Identity.GetUserId()) { return(HttpNotFound()); } model.CreditCard.ClearCreditCardDetails(); return(View(model)); }
public async Task<ActionResult> ChangeCreditCard(CreditCardViewModel model) { var userId = User.Identity.GetUserId(); if (ModelState.IsValid && await CardService.CardBelongToUser(model.CreditCard.Id, userId)) { var user = await UserManager.FindByIdAsync(userId); await CardService.UpdateAsync(user, model.CreditCard); // TempData.Add("flash", new FlashSuccessViewModel("Your credit card has been updated successfully.")); return RedirectToAction("Index"); } return View(model); }
public async Task<ActionResult> ChangeCreditCard(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var model = new CreditCardViewModel { CreditCard = await CardService.FindAsync(User.Identity.GetUserId(), id) }; // If the card doesn't exist or doesn't belong the logged in user if (model.CreditCard == null || model.CreditCard.SaasEcomUserId != User.Identity.GetUserId()) { return HttpNotFound(); } model.CreditCard.ClearCreditCardDetails(); return View(model); }
public async Task<ActionResult> AddCreditCard(CreditCardViewModel model) { if (ModelState.IsValid) { var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); await CardService.AddAsync(user, model.CreditCard); // TempData.Add("flash", new FlashSuccessViewModel("Your credit card has been saved successfully.")); return RedirectToAction("Index"); } return View(model); }