public async Task <PersonPhoneResponse> AddPersonPhone(PersonPhoneDto personPhone) { var person = await _personService.Find(personPhone.PersonId); var newPersonPhone = new PersonPhone { PhoneNumber = personPhone.PhoneNumber, PhoneNumberType = await _phoneNumberTypeService.Find(x => x.Name == personPhone.PhoneNumberType), Person = person }; await _personPhoneService.Add(newPersonPhone); var response = new PersonPhoneResponse { PersonPhoneObject = new PersonPhoneDto { BusinessEntityID = newPersonPhone.BusinessEntityID, PersonId = newPersonPhone.Person.BusinessEntityID, PhoneNumber = newPersonPhone.PhoneNumber, PhoneNumberType = newPersonPhone.PhoneNumberType.Name } }; return(response); }
public async Task <PersonPhoneResponse> Add(PersonPhoneDto personPhoneDto) { var personPhone = _mapper.Map <PersonPhoneDto, PersonPhone>(personPhoneDto); var personPhoneResponse = await _personPhoneService.Add(personPhone); var response = new PersonPhoneResponse(); response.PersonPhoneObject = new PersonPhoneDto(); response.PersonPhoneObject = _mapper.Map <PersonPhone, PersonPhoneDto>(personPhoneResponse); return(response); }