Reputation: 987
So I have a method that receives an array of ids of a given entity in our database, I search in the db for those ids, and the ones that were not found I store them in DB, after that I return an array of those entities containing the ones that were already created and the new ones.
Since this entity has relations with a diversity of other entities, this logic is expected to be consumed by many command/query handlers, where should I put this logic?
Upvotes: 0
Views: 684
Reputation: 663
I would definitely create a class which encapsulates your logic and inject this class in the command/query handlers.
At first glance, maybe creating a repository class for this entity would be great too, you could encapsulate this logic there.
Upvotes: 1