during the last days I've read some tutorials and topics about the Repository Pattern and the Unit of Work.
I was able to understand the UoW idea, and it's a very good one, my problem now is how to replicate something like this to the Service layer (which would be my BLL). I have a thought stuck in my head and I hope I can be clear enough about it, maybe I haven't understood the concept properly.
Let's imagine the following:
I have a
ClientServiceand aOrderService.In my Client service I have a method called
RemoveClientIn my Order service I have a method called
RemoveOrder
On one hand, when I call my RemoveClient method, I'll check a ton of stuff before allowing it to be deleted and in cases of deletion I'll delete all of his orders too. On the other hand, when I call my RemoveOrder I'll have other stuff to check before deleting it too (different stuff from the RemoveClient method), all of these deleting rules are contained in my Service Layer.
In most of the examples I've seen lately, a Service always calls the UoW of the repository, but since there's no business logic on my repository it doesn't make sense to me. When I'm deleting my Client isn't it better to always call the OrderService from my ClientService instead of calling the ClientRepository and OrderRepository directly from my ClientService, this way making sure that all the validations are being done for both elements.
If it is better to always call the Services (to keep the business logic "flowing") how could I keep the Services in the same context (like UoW does for the Repository).
I hope I was clear enougth. Thank you.