S
shapper
Hello,
I am following ASP.NET MVC Storefront example available in CodePlex:
http://www.codeplex.com/mvcsamples
As far as I know a Repository Interface, ICatalogRepository, defines
methods like GetProducts, GetCategories, ...
And a class inheriting that repository, for example
SQLProductRepository, defines the methods and what they return or save
in the database .. in this case using Linq.
What I am missing is: the controllers use Services (there is a
ICatalogService and CatalogService).
The problem is that it seems they do the same???
In my MVC Application I have:
1. A LinqToSql Model with two tables (classes): Article and Tag.
Each Article is related to one or many tags;
2. Two classes, MvcArticle and MvcTag that map LinqToSql classes.
MvcArticle contains the same properties as Article and an extra:
List<MvcTag>.
So when I get an Article I also need to get the tags related to it ...
and when I save an article I need to provide the tags related to it.
I need 5 methods: GetArticles, GetArticleById, CreateArticle,
DestroyArticle and UpdateArticle.
I have this methods declared in IArticleRepository and defined, using
Linq to create the funcionality, in SqlArticleRepository.
The question is: where the services should be doing and why to create
them?
Shouldn't the controller call the repository?
I am confused about this ...
Thanks,
Miguel
I am following ASP.NET MVC Storefront example available in CodePlex:
http://www.codeplex.com/mvcsamples
As far as I know a Repository Interface, ICatalogRepository, defines
methods like GetProducts, GetCategories, ...
And a class inheriting that repository, for example
SQLProductRepository, defines the methods and what they return or save
in the database .. in this case using Linq.
What I am missing is: the controllers use Services (there is a
ICatalogService and CatalogService).
The problem is that it seems they do the same???
In my MVC Application I have:
1. A LinqToSql Model with two tables (classes): Article and Tag.
Each Article is related to one or many tags;
2. Two classes, MvcArticle and MvcTag that map LinqToSql classes.
MvcArticle contains the same properties as Article and an extra:
List<MvcTag>.
So when I get an Article I also need to get the tags related to it ...
and when I save an article I need to provide the tags related to it.
I need 5 methods: GetArticles, GetArticleById, CreateArticle,
DestroyArticle and UpdateArticle.
I have this methods declared in IArticleRepository and defined, using
Linq to create the funcionality, in SqlArticleRepository.
The question is: where the services should be doing and why to create
them?
Shouldn't the controller call the repository?
I am confused about this ...
Thanks,
Miguel