Guest User

Untitled

a guest
Mar 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. public class AutoMapperConfig
  2. {
  3.  
  4. public static void RegisterMappings()
  5. {
  6.  
  7. Mapper.Initialize(x =>
  8. {
  9. x.AddProfile<DomainToViewModelMappingProfile>();
  10. x.AddProfile<ViewModelToDomainMappingProfile>();
  11. });
  12.  
  13. }
  14. }
  15.  
  16. public class DomainToViewModelMappingProfile : Profile
  17. {
  18.  
  19. public override string ProfileName
  20. {
  21. get { return "ViewModelToDomainMappings"; }
  22. }
  23.  
  24. protected override void Configure()
  25. {
  26. CreateMap<ClienteViewModel, Cliente>();
  27. CreateMap<ProdutoViewModel, Produto>();
  28. }
  29.  
  30. }
  31.  
  32. public class ViewModelToDomainMappingProfile : Profile
  33. {
  34.  
  35. public override string ProfileName
  36. {
  37. get { return "DomainToViewModelMappings"; }
  38. }
  39.  
  40. protected override void Configure()
  41. {
  42. CreateMap<ClienteViewModel, Cliente>();
  43. CreateMap<ProdutoViewModel, Produto>();
  44. }
  45. }
Add Comment
Please, Sign In to add comment