public ActionResult Withdraw(WithdrawViewModel withdrawViewModel) { if (ModelState.IsValid) { if (CardsService.HasEnoughMoney(User.CardId, Convert.ToDecimal(withdrawViewModel.Amount))) { if (OperationsService.WithdrawMoney(User.CardId, Convert.ToDecimal(withdrawViewModel.Amount))) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Could not withdraw money. Try again"); } } else { ModelState.AddModelError("", "Not enough money on the card balance"); } } var currentCardBalance = CardsService.GetBalance(User.CardId); ViewData["currentCardBalance"] = currentCardBalance; return(View()); }
public ActionResult Withdraw() { var currentCardBalance = CardsService.GetBalance(User.CardId); ViewData["currentCardBalance"] = currentCardBalance; return(View()); }