posted 5 years ago
Well, isn't a repository really already a kind of service? Why would you add yet another layer of indirection if you can just let the controller interact with the repository directly?
This is my usual flow:
1) Request with data transfer objects comes in.
2) Controller translates data transfer objects to domain objects.
3) Controller performs logic with domain objects.
4) Controller passes domain objects to the injected repository.
5) Repository translates domain objects to entities (data transfer objects for the database).
6) Entities are serialized to database or deserialized from database.
7) Repository translates entities to domain objects and returns them to the controller.
8) Controller performs logic with domain objects.
9) Controller translates domain objects to data transfer objects.
10) Controller sends response with data transfer objects.