// GET api/values/5 //using the injected mapper public PersonViewModel Get(int id) { var personDom = new Person { Age = (decimal)30.00, FirstName = "Rahul", LastName = "Ballal", Id = 10 }; return _mappingEngine.Map<PersonViewModel>(personDom); }
// GET api/values // using the static mapper method public IEnumerable<PersonViewModel> Get() { var personDom = new Person { Age = (decimal)30.00, FirstName = "Rahul", LastName = "Ballal", Id = 10 }; // basic mapping var personVm = Mapper.Map<PersonViewModel>(personDom); // reverse mapping var pdom2 = Mapper.Map<Person>(personVm); // using custom mapping var plistvm = Mapper.Map<PersonListViewModel>(personDom); return new[] {personVm}; }