public IActionResult Transfer(int id, BankAccountTransferViewModel bankAccountTransferViewModel) { if (ModelState.IsValid) { if (bankAccountTransferViewModel.BankAccountIDToTransfer.HasValue && bankAccountRepository.DoesBankAccountExists(bankAccountTransferViewModel.BankAccountIDToTransfer.Value)) { try { bool withdrawOperationResult = bankAccountRepository.TransferAmountFromAccountToAccount(id, bankAccountTransferViewModel.BankAccountIDToTransfer.Value, bankAccountTransferViewModel.AmountCurrent, bankAccountTransferViewModel.AmountToTransfer, bankAccountTransferViewModel.ModifiedDate); if (withdrawOperationResult) { return(RedirectToAction("Index", "BankAccount", new { @id = id })); } } catch (InvalidBankAccountModifiedTimeStamp ex) { //ViewData["AmountToTransferError"] = "The Amount of the Bank account has been modified Please, refresh the page and try to deposit again!"; return(RedirectToAction("Transfer", "BankAccount", new { @id = id })); } catch (InvalidBankAccountWithdrawException ex) { ModelState.AddModelError("AmountToWithdraw", "The Amount of money to withdraw exceeds the Amount of money in the Bank Account!"); } catch (Exception ex) { ModelState.AddModelError(string.Empty, "Something wen wrong! Please retry the operation!"); } } else { ModelState.AddModelError("BankAccountIDToTransfer", "The target Account ID does not exists!"); } } return(View(bankAccountTransferViewModel)); }