public async Task <int> AddWithPhonesAsync(PersonWithPhonesDTO personWithPhonesDTO) { Person person = new Person(); mapper.Map(personWithPhonesDTO, person); var personId = await unitOfWork.PersonRepository.AddAsync(person); foreach (var phone in personWithPhonesDTO.PhonesList) { phone.IdPerson = personId; await unitOfWork.PhoneRepository.AddAsync(phone); } unitOfWork.Complete(); return(personId); }
public async Task <IActionResult> AddWithPhones(PersonWithPhonesDTO personWithPhones) { return(Ok(await personBL.AddWithPhonesAsync(personWithPhones))); }