In asp.net MVC 4, I have 2 DomainModels
- Product
- Order
and a related ViewModel
- OrderDetailsViewModel
In my "OrderDetailsViewModelMapper" mapper file I am manually mapping these 2 DomainModels to my ViewModel. Mapper file "OrderDetailsViewModelMapper" will call my repository method which will access the DB and return back my 2 DomainModels i.e.Product and Order after mapping them inside repository itself. So mapper just calling repository and getting it's DomainModels. I don't want Automapper. Now I have 2 questions on this scenario.
- Whether the above mentioned flow to fill my ViewModel is violating any best practices?
- Can I keep 2 properties of type Product & Order inside my "OrderDetailsViewModel" like below and just map those properties only rather than duplicate all properties inside "OrderDetailsViewModel" too and map tem individually?
public class OrderDetailsViewModelMapper
{
public Product Product{ get; set; }
public Order Order{ get; set; }
}