public IActionResult Transfer(TransferVM model) { var repo = BankRepository.Instance(); if (ModelState.IsValid) { try { var fromAccount = repo.GetAccount(model.fromAccountNumber); var recievingAccount = repo.GetAccount(model.recievingAccountNumber); repo.Transfer(fromAccount, recievingAccount, model.Amount); var transferVM = new TransferVM(); transferVM.FromAccount = AccountVM.Create(fromAccount); transferVM.RecievingAccount = AccountVM.Create(recievingAccount); return(View("TransferSuccess", transferVM)); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } } return(View("Index", model)); }
public IActionResult Deposit(TransactionVM model) { var repo = BankRepository.Instance(); if (ModelState.IsValid) { try { var account = repo.GetAccount(model.AccountNum); repo.Deposit(account, model.Amount); var accountVM = AccountVM.Create(account); return(View("TransactionSuccess", accountVM)); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } } return(View("Index", model)); }