I can use default design of MVC solution. For example, controller:
public class ProductController : Controller
{
private Entities db = new Entities();
public ViewResult Details( int id )
{
Product product = db.Products.Single( p => p.ID == id );
return View( product );
}
}
But I saw in some large projects, to call any method, they used only service, for example
public class ProductController : Controller<ISomeService>
{
public ViewResult Details( int id )
{
Product product = MyService.GetProductById();
return View( product );
}
}
and not using database instance in the controller such as:
private Entities db = new Entities();
Models, DB and Business Logic are different projects in solution.
From where can I learn about this structure in any sample? (sorry for bad English)
I would take a look at using dependency injection with ASP.NET MVC, here's an article on the subject:
Then take a look at using a Repository/UnitOfWork pattern with Entity Framework, another article:
http://www.codeproject.com/Tips/309753/Repository-Pattern-with-Entity-Framework-4-1-and-C
And if you're not interested in doing all this code on your own, you can use, or at least take a look at how it can be done, here: