public static UpdateTransactionCommand MapToCommand(this TransactionPutRequest transaction, int id)
        {
            if (transaction is null)
            {
                return(null);
            }

            return(new UpdateTransactionCommand(
                       id,
                       transaction.TransactionType,
                       transaction.Date,
                       transaction.Value,
                       transaction.AccountId));
        }
        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()));
            }
        }