Should my controllers or services commit changes to database?
I currently have:
Core:
- Invoice
- Ticket
Application
Repositories:
- IInvoiceRepository
- ITicketRepository
Services:
- IInvoiceService (gets invoices including their ticket)
Infrastructure
- UnitOfWork (using DbContext and repositories as properties)
- Repository implementation
- Service implementation
Option 1:
InvoiceController.Delete:
var item = InvoiceService.GetAll()
InvoiceService.DeleteFull(item);
UoW.Commit();
Option 2:
InvoiceController.Delete:
var item = InvoiceService.GetAll()
InvoiceService.DeleteFull(item); // inside calls UoW.Commit();