I just recently started to experiment with .NET MVC 4.
The thing is I have a WCF service that provides data for several application and would like to use it for a site using MVC as well.
Im totally new to this, so Im wondering where the best place to connect to the WCF is. I guess that the WCF could be considered to be the model, and in that case the best way would be to place it in a controller.
But is this really correct or should the service be consumed in the model layer?
I tend to architect this using a repository pattern where the repository methods return instances of my model classes:
Inside my controller I will simply instantiate a reference to my repository and call the appropriate methods. The repository will wrap the WCF service proxy and call the service(s) inside the various repository methods
EX from CustomerController:
I also tend to have my repositories implement an interface to make it easy to mock the data access layer without having to call external dependencies like the WCF service/database (unit tests)