Controller -> Service -> Repository: Does service map Entity to ViewModel?

Viewed 5796

I haven MVC app, with "M" including Service and Repository layers.

However, I am a little confused as to where and how to do a couple of things.

  1. One Service calling two repositories, or calling it's own repository and another service

e.g.

I have a ReferenceDataService, which handles all of the logic for CRUD with my reference tables.

Then in my "CustomerService" I need to 'R' my reference data to get e.g. Description instead of Id. So, do I call the ReferenceDataService or ReferenceDataRepository?

  1. At some layer I'd like to map from Entity to ViewModel.

Do I do this in my Service layer, or in the Controller?

e.g. Does my ServiceLayer do the mapping/logic from VM to Entity and back?

Thanks:)

2 Answers
Related