How to organize the viewmodels and mappings in the project? [closed]

-1

Good morning everyone! I am studying about mapping (model and viewmodel) using implicit operators. But I had a question: How to organize the viewmodels and mappings within the project? Where should I save classes? Inside the model class file or create a own or even, a folder only for viewmodels? And about the mapping, which "place" should I write the code to?

Thanks in advance for the help!

    
asked by anonymous 03.05.2016 / 15:43

1 answer

0

Since ViewModels are only intended to serve modeling / typing Views, it should stay in the presentation project - if it is MVC, in the Web project, if it is WebAPI, in the API project. Should not be in the same project of the models, as they belong to another context.

To help with Models <-> ViewModels mapping, I use AutoMapper . Very easy to implement and very fast. Here's a file from Eduardo Pires on AutoMapper and ViewModels . It will help you implement this pattern.

    
03.05.2016 / 17:20