Actually im doing a home page that only have an action called Index() that returns the view Index.ascx.
This index page will be composed by lastest news and lastest registered users, i think that create two partial views is the best idea (this way i could use it in other views).
for other hand i have a data access class that calls to database for get stuff (get last news, get last users, etc…)
My question is simple, should i call to the this data access class in the Index() action of my HomeController, and add to the ViewData the data obtained?
I think that this index() action shouldnt be the responsable of passing this data to the partial views, right?
Could you give me a hand?
im messing too much? 😉
Thanks in advance.
Best Regards.
Jose
I suggest you use Action methods to control only to decide display content and not what it displays.
I would say encapsulate the Data Access logic in one more layer , so that it is loosely coupled from the controller actions.
This results in having ‘Thinner actions and Coarser Models’ . You might want to use a repository pattern as described in Scotts blog or follow Domain Driven Design which illustrates the responsibility of each of the layers.
Hope this helps.
Thanks ,
Vijay