Exemple #1
0
        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());
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        public bool AddPhone(Phone phone)
        {
            bool isValid = _phoneValidator.Validate(phone);

            if (!isValid)
            {
                return(false);
            }

            _phoneRepo.AddPhone(phone);

            return(true);
        }
Exemple #4
0
 public async Task <ServiceResult> AddPhone(PhoneAdd model)
 {
     return(await _phoneRepository.AddPhone(model));
 }
Exemple #5
0
 public async Task AddPhone(Phone phone)
 {
     await _repository.AddPhone(phone);
 }