Let's assume that I have an
Order object that has a
List<OrderItem> , the user goes to page and creates his order, now I should save his selection to the database, I have two data service classes one for each entity,
OrderItemDataService, which is more correct?
1- At presentation level in the
Add button I write a code that calls
OrderDataService.Add(Order order) method then loop through
List<OrderItem> and call
OrderItemDataService.Add(OrderItem item) for each
OrderItem making the transaction happen at the level of presentation behind the
2- Create a method in the
OrderService.AddWithItems(Order order, List<OrderItem> items) that takes Order and OrderItem as parameter and make this method handle the looping and transaction?
Note: This is a very simple example, in practice things are more complicated and creating an OrderService.AddWithItems() method could end up taking too many paramters.