public IActionResult AddPerson([FromBody] Models.Person.PersonModel model, bool userOverride = false) { // Business rule - support country free-form value if country code is "Other". Ignore field otherwise. var otherCountry = _pimsRepository.Lookup.GetCountries().FirstOrDefault(x => x.Code == Dal.Entities.CountryCodes.Other); foreach (var address in model?.Addresses) { if (otherCountry != null && address != null && address.CountryId != otherCountry.CountryId) { address.CountryOther = null; } } var entity = _mapper.Map <Dal.Entities.PimsPerson>(model); try { var created = _pimsService.PersonService.AddPerson(entity, userOverride); var response = _mapper.Map <Areas.Contact.Models.Contact.PersonModel>(created); return(new JsonResult(response)); } catch (DuplicateEntityException e) { return(Conflict(e.Message)); } }
public IActionResult UpdatePerson([FromBody] Models.Person.PersonModel personModel) { var personEntity = _mapper.Map <Pims.Dal.Entities.PimsPerson>(personModel); var updatedPerson = _pimsService.PersonService.UpdatePerson(personEntity, personModel.RowVersion); return(new JsonResult(_mapper.Map <Models.Person.PersonModel>(updatedPerson))); }