I'm new to Domain Driven Design and trying to figure out what should put where. Assume I have a class called Order and a related DTO called OrderDto.
The front end calls the OrderController (MVC architecture) by passing the OrderDto and the controller calls the OrderService.
Then I use OrderRepository to get the Order from the database and update the Order using OrderDto. Assume I want to calculate Total, VAT and Subtotal every time, a customer Add/ Edit orders. The Question is, in the DDD where should I put these calculations.
- In the service layer as private methods such as RecalculateTotal or in a helper class as a Static method
- Inside the behaviour class
- Inside the Domain (Class member setters)
At the moment I do it in the service layer but I'm certain I have missed something. Because every time a user add or remove product from his order I have to call my recalculation methods manually. I think this calculation should be done automatically. So I don't have/ need to worry about these calculation.
Any help would be much appreciated.
Update 1
in summery where we should put our business rules in DDD?