2

Project setup:

MVC project, business layer that depends on repository pattern for working with data.

Question:

Sometimes you want the business layer to return data that is not a simple List<entitytype>. In that case, should your strongly typed view use the return value (some business model) of the business layer method or should you always use a viewmodel in the mvc model folder.

What is best practice?? If i use TDD for defining my business methods, my end point would be a model that implements the requirements that can be used by the view to display data, so the controller can simply pass that to the view. Is that bad and should i really use an model in the mvc project to be the interface between the controller and the view?

In any case, my MVC project depends on the business layer.. Is it bad to use return value models from the business layer to pass data from my controllers to my views?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Somehow i get an impression that this is more about the ASP.NT MVC framework, then about MVC as design pattern. They are not the same thing. It is like referring to IE as "the internet". – tereško Jul 06 '12 at 00:08

1 Answers1

1

Best practice to follow and save time is usage of AutoMapper, which will save you ton of time. Good post to follow would be - View Model pattern and AutoMapper in ASP.NET MVC Applications

However there are some good practices to follow:

Community
  • 1
  • 1
Yusubov
  • 5,815
  • 9
  • 32
  • 69
  • while reading question, i got a strong impression that this is .net. however, author of post would need to clarify the development platform. – Yusubov Jul 06 '12 at 10:13