public IActionResult Deposit([FromBody] TransactionOperationsRequest withdraw) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Account account = _accountService.Deposit(withdraw.AccountNumber, withdraw.Value); return(Ok(new AccountOperationsResponse(account))); } catch (ParametersLessThanZeroException) { return(BadRequest("Account Number and transaction value must be positive.")); } catch (AccountNotFoundException) { return(BadRequest("Account Number not found.")); } catch (AccountBlockedException) { return(BadRequest("Account is blocked.")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public IActionResult Withdraw([FromBody] TransactionOperationsRequest withdraw) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Account account = _accountService.Withdraw(withdraw.AccountNumber, withdraw.Value); return(Ok(new AccountOperationsResponse(account))); } catch (ParametersLessThanZeroException) { return(BadRequest("Account Number and transaction value must be positive.")); } catch (AccountNotFoundException) { return(BadRequest("Account Number not found.")); } catch (AccountBlockedException) { return(BadRequest("Account is blocked.")); } catch (WithdrawLimitExceededException) { return(BadRequest("Account withdraw limit exceeded.")); } catch (BalanceInsufficientException) { return(BadRequest("Account does not have balance enough.")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }