コード例 #1
0
        public void Editar(EditarTelefoneCommand editarTelefoneCommand)
        {
            ValidarPropriedades(editarTelefoneCommand.DDD, editarTelefoneCommand.Numero);

            DDD    = editarTelefoneCommand.DDD;
            Numero = editarTelefoneCommand.Numero;
        }
コード例 #2
0
        public void EditarTelefone(EditarTelefoneCommand editarTelefoneCommand)
        {
            ValidacaoLogica.IsTrue <ValidacaoException>(editarTelefoneCommand is null, "Comando de edição de telefone não pode ser nulo.");

            var cliente = clientesRepository.ObterUm(x => x.Cpf == editarTelefoneCommand.Cpf);

            ValidacaoLogica.IsTrue <RecursoNaoEncontradoException>(cliente is null, "Cliente não encontrado.");

            ValidacaoLogica.IsTrue <RecursoNaoEncontradoException>(cliente.Telefones is null, "Este cliente não possui telefone cadastrado.");

            ValidacaoLogica.IsFalse <RecursoNaoEncontradoException>(cliente.Telefones.Any(x => x.Id == editarTelefoneCommand.Id),
                                                                    "Só é possível editar um telefone existente para esse cliente.");

            ValidacaoLogica.IsTrue <ValidacaoException>(cliente.Telefones.Any(x => editarTelefoneCommand.DDD == x.DDD &&
                                                                              editarTelefoneCommand.Numero == x.Numero),
                                                        "Esse número já está cadastrado para esse cliente.");

            cliente.Telefones.FirstOrDefault(x => x.Id == editarTelefoneCommand.Id).Editar(editarTelefoneCommand);

            clientesRepository.Atualizar(cliente);

            unitOfWork.SaveChanges();
        }
コード例 #3
0
 public void AdicionarTelefone(long id, EditarTelefoneCommand editarTelefoneCommand)
 {
     editarTelefoneCommand.Id = id;
     telefonesAppService.EditarTelefone(editarTelefoneCommand);
 }