public IActionResult Deposit(int id, BankAccountDepositViewModel bankAccountDepositViewModel) { if (ModelState.IsValid) { try { bool depositOperationResult = bankAccountRepository.DepositAmountIntoBankAccount(id, bankAccountDepositViewModel.AmountCurrent, bankAccountDepositViewModel.AmountToDeposit, bankAccountDepositViewModel.ModifiedDate); if (depositOperationResult) { return(RedirectToAction("Index", "BankAccount", new { @id = id })); } } catch (InvalidBankAccountModifiedTimeStamp ex) { //ViewData["AmountToDepositError"] = "The Amount of the Bank account has been modified Please, refresh the page and try to deposit again!"; return(RedirectToAction("Deposit", "BankAccount", new { @id = id })); } catch (Exception ex) { ModelState.AddModelError(string.Empty, "Something wen wrong! Please retry the operation!"); } } return(View(bankAccountDepositViewModel)); }
public IActionResult Deposit(int id) { var bankAccountDTO = bankAccountRepository.GetBankAccountDTOById(id); BankAccountDepositViewModel bankAccountDepositViewModel = BankAccountMapHelpers.MapBankAccountDTOToDepositViewModel(bankAccountDTO); return(View(bankAccountDepositViewModel)); }
public static BankAccountDepositViewModel MapBankAccountDTOToDepositViewModel(BankAccountDTO bankAccountDTO) { BankAccountDepositViewModel bankAccountDepositViewModel = new BankAccountDepositViewModel { ID = bankAccountDTO.ID, AmountCurrent = bankAccountDTO.Amount, Owner = bankAccountDTO.Owner.UserName, AmountToDeposit = 0, ModifiedDate = bankAccountDTO.ModifiedDate }; return(bankAccountDepositViewModel); }
public async Task <ActionResult <IValidationResult> > DepositAsync(BankAccountDepositViewModel bankAccount) { var result = await _bankAccountAppService.DepositAsync(bankAccount); return(CustomResponse(result)); }