As an example, the customer service has a method that cancels a particular order for that customer:
public class CustomerService : ICustomerService<Customer>
{
public void CancelOrder(int orderNo)
{
//customerRepository here...
}
}
Then, another service used for batch processing can also cancel multiple orders:
public class BatchService : IBatchService
{
public void CancelOrders(params int[] orderNos)
{
//What here?
}
}
The code for cancelling the customer's order is located in the CustomerService
. Should the BatchService
call CustomerService.CancelOrder
or should it just use the customer repository too?
I wouldn't write the cancelling logic twice. Where you have it is up to you, but given your current structure, I'd inject ICustomerService into BatchService. So class could look something like