public async Task <IActionResult> Update([FromRoute] int accountNumber, [FromRoute] double amount) { var account = await _bankService.GetAccountByIdAsync(accountNumber); if (account == null) { return(NotFound()); } try { double netBalance = Account.CalculateBalance(account.Balance, amount); account.Balance = netBalance; var updated = await _bankService.UpdateAccountAsync(account); if (updated) { return(Ok(account)); } return(NotFound()); } catch { return(BadRequest(new { error = "Insufficient Balance" })); } }