I need to show an object (POCO class) in the form.
In my controller, I get object data from the object repository.
But in the form I should also show some additional data about the object, such as the name of the country, not the countryid, the number of persons assigned (to get from the 1: N relationship), the history of changes (to be extracted from another table) and the "CanBeCancelled" bit .
Question: where should I put this logic?
I came up with these alternatives:
- Repository itself: create an extra function that returns this exact view model
- conversion service that converts the class to viewmodel (he knows where to get the data)
- controller: it knows what data should be displayed in the view (model), so it should get all the data from different repositories
What is a good way to host this logic (using “this logic” I mean logic to know that the number of people is selected in repository A, the history is fetched by repository B, and the countryname is fetched by CountryRepository and the boolean “CanBeCancelled” is fetched by StateEngine)?
source share