Is it possible to add a bunch of static methods in the viewmodel
No , your view model should just be a POCO containing a small (if not zero) business logic. The task only for viewing models is to move data from the controller to the view.
Generally:
- The controller should get an instance of the model somewhere
- it can be consumed directly, or if several models are required, combination or additional information is required (not in the model as such), then a presentation model can be created.
- Ideally, the presentation model should be created outside the controller (maintaining the performance of the controllers), this can be achieved simply using the factory template
If you are reading the wikipedia page for the MVC template. You will notice that it is intended solely for presenting data, and not for business logic:
Model-view-controller (MVC) is a software architectural template for implementing user interfaces .
so none of the MVC objects (model, view, or controller) should contain business logic. The goal of MVC patterns is to provide data (full stop)
All of the above says that the controller includes simple business logic. However, if sites become more complex, this should be avoided for fear of creating an object.
source share