// POST api/values //Test with e.g. //$.ajax("http://localhost:.../api/values", { type : 'POST', data : { firstName : 'Florian', lastName : 'Rappl' } }) public void Post([FromBody]PersonDTO person) { var p = new Person(); p.FirstName = person.FirstName; p.LastName = person.LastName; book.Persons.Add(p); book.SaveChanges(); }
public PersonDTO(Person person) : this() { Id = person.Id; FirstName = person.FirstName; LastName = person.LastName; for (int i = 0; i < person.PhoneNumbers.Count; i++) PhoneNumbers.Add(new PhoneNumberDTO(person.PhoneNumbers[i])); for (int i = 0; i < person.Addresses.Count; i++) Addresses.Add(new AddressDTO(person.Addresses[i])); }