Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net MVC and N-Tier

Greetings,

Apologies in advance that I have not researched this toughly enough to answer the question myself, but I imagine it would take me some time and I would rather know now before I invest more time in learning it. I couldn't find anything in my initial research..

Why use ASP.Net MVC if your already using a multi-tier architecture (Data Layer, Logic Layer, Presentation Layer)? Other than the fact the controller has more power than the logic layer.

Am I right in thinking I can use nHibernate and all my data access classes, entities, and mappings in the Model part of the MVC?

When using controllers, is it best to separate a lot of the logic into a separate class so I can call it from multiple controllers? Or can I call them from the controllers themselves, considering the fact that I would not want all of them to be Actions, just normal methods.

Thanks

like image 326
Damien Avatar asked Dec 09 '22 22:12

Damien


2 Answers

MVC is not to replace N-Tier, it is a way to organize the presentation layer.

I would not say that the controller is more powerful than the logic layer. Instead, the controller (as a part of the presentation layer) should still call the logic layer.

Controllers should only prepare data for views and handle actions from views. You should still use your BLL.

like image 74
gius Avatar answered Jan 01 '23 18:01

gius


Yes, NHibernate entities can (and they should be) be passed to the views.

This will you get you into some trouble. You should use flattened, null-safe DTOs a.k.a. view models.

like image 25
Matt Hinze Avatar answered Jan 01 '23 19:01

Matt Hinze