Hello,
I think I'm beginning to be confused with the job of a controller in MVC.
I have a service that exposes five functions:
- list packages in queue
- get package
- delete package
- accept package
- deny package
My ASP.NET MVC controller depends on this service, and can generally execute a service call on an Action. I'm happy so far.
The second part is then building the ViewModel result. If I do this inside of the controller, the controller now has an exploding dependency list -- each action added increases the dependencies in order to build the view model, and these are all inherited by the controller. I don't like this very much. I'm building this controller that depends on N different view model builders, but only using one of them per request.
So I was thinking of pulling all of this out and applying action filters specific to each view model. I haven't done this yet, but it seems okay.
The question this is raising for me is: what is the responsibility of the controller? If I end up pulling the view model building into filters, my controller is doing little more than having a route execute a service call (and providing a filter plugin). If I instead leave my controller responsible for building each view model, it becomes a mess.
It seems like I almost want to instantiate an action per request, not a controller, and I'm just abusing filters to get at that?