mardi 20 septembre 2016

Is good practice to extract request into multiple commands?

At my system when a new transaction added to the system, that request has the following information

  • A) the client that made the transaction
  • B) if the transaction will be paid by installments, and the frequency of the installments (monthly, evvery 15 days etc.)

Also if the transaction will not be paid by installments the analysis data must get updated (clear-in of current month etc).

So when a new transaction submitted by the users the 4 following must be done

  • 1) Add a new client if the client in the request does not exist
  • 2) Add the new transaction into the database

    and if there are installments

  • 3) add the installments into the database

else

  • 4) update analysis data

So the solution to this is at my controller AddnewTransactionController extract the request into two separate commands AddNewClientCommand AddNewTransactionCommand and invoke the associated command handlers AddNewClientCommandHadler AddNewTransactionCommandHandler.

Also the AddNewTransactionCommandHandler will have domain services injected like UpdateanalysisData.

Does the above consider a good solution from architectural point of view?

Aucun commentaire:

Enregistrer un commentaire