public IActionResult AddPerson(EntityModels.Person person) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var addedPerson = _personService.AddPerson(person); return(Created($"/api/v1/persons/{addedPerson.PersonId}", addedPerson)); }
public Person AddPerson(EntityModels.Person newPerson) { if (newPerson == null) { throw new ArgumentNullException("newPerson"); } _context.Persons.Add(newPerson); _context.SaveChanges(); return(new Person { FirstName = newPerson.FirstName, LastName = newPerson.LastName, PersonId = newPerson.PersonId }); }