public async Task <IActionResult> AddPhone([FromBody] Phone model) { if (ModelState.IsValid) { try { var phoneId = await phoneRepository.AddPhone(model); if (phoneId > 0) { return(Ok(phoneId)); } else { return(NotFound()); } } catch (Exception) { return(BadRequest()); } } return(BadRequest()); }
public bool UpdateContact(Contact model) { foreach (Phone phone in model.Phones.Where(x => x.Id == Guid.Empty)) { phone.Id = Guid.NewGuid(); phone.IdContact = model.Id; phoneRepository.AddPhone(phone); } contactRepository.UpdateContact(model); return(true); }
public bool AddPhone(Phone phone) { bool isValid = _phoneValidator.Validate(phone); if (!isValid) { return(false); } _phoneRepo.AddPhone(phone); return(true); }
public async Task <ServiceResult> AddPhone(PhoneAdd model) { return(await _phoneRepository.AddPhone(model)); }
public async Task AddPhone(Phone phone) { await _repository.AddPhone(phone); }