Skip to main content
1 of 2
Christophe
  • 80.6k
  • 11
  • 132
  • 199

You are fully right. The MVC should have the business logic and the data access layer in the Model. The Controller should manage user input and transforms it into commands either for the View or for the Model. There should be no buisness logic here.

But the code snippet you show (from here?) from the controller does not seem to infringe this segregation of concerns:

It‘s not business logic: its logic is to query the model (_context is not a db context, but an MvcContext, i.e. an object to access the model). It uses the result to create a View.

But it’s not completely classical MVC either. In the original MVC, the logic would be to create a view and passing it it the id, and let the view query the model (and the model notify the view if data changes). The snippet‘s approach looks more like an MVP to me, where P is the mediator between model and view.

Christophe
  • 80.6k
  • 11
  • 132
  • 199