public IActionResult DeleteTransaction(int transactionId) { if (transactionId == null) { return(BadRequest()); } try { var command = new DeleteTransactionCommand(transactionId); var commandHandler = new TransactionCommandHandler(_transactionRepository); commandHandler.Handle(command); return(Ok()); } catch (CommandValidationException <eTransactionsError> ex) { return(BadRequest(ex.Error.ToString())); } }
public IActionResult PutTransaction([FromBody] TransactionPutRequest transactionPutRequest, [FromRoute] int transactionId) { if (transactionPutRequest == null || transactionId == null) { return(BadRequest()); } try { var command = transactionPutRequest.MapToCommand(transactionId); var commandHandler = new TransactionCommandHandler(_transactionRepository, _accountRepository); var transaction = commandHandler.Handle(command); var response = transaction.MapToResponse(); return(Ok(response)); } catch (CommandValidationException <eTransactionsError> ex) { return(BadRequest(ex.Error.ToString())); } }