My advice is to create separate classes called "services". Put them in a class library project (or namespace) and make them independent in the MVC infrastructure infrastructure. I recommend using some dependency injection as well (best of all, constructor injection). Then your service classes might look like this:
public class MyService : IMyService { IFirstDependency _firstService; ISecondDependency _secondService; public MyService(IFirstDependency firstService, ISecondDependency secondService) { } public Result DoStuf(InputDTO) {
Then you use these services on your controllers. Look here for a complete example.
According to the repositories - my advice is to not use them if you intend to use some modern ORMs (NHibernate, EntityFramework), since your business logic will be encapsulated at the service level and your database will already be encapsulated with the ORM framework.
Marian Ban Feb 15 '13 at 9:55 2013-02-15 09:55
source share