Пример #1
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            if (dgvPesquisaContato.RowCount > 0)
            {
                if (MessageBox.Show("Deseja excluir?", "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    TelefoneRepository repositoryTelefone = new TelefoneRepository();

                    int      codigo        = Convert.ToInt32(dgvPesquisaContato.CurrentRow.Cells[0].Value.ToString());
                    Telefone telefoneModel = repositoryTelefone.RetornarPorId(codigo);

                    try
                    {
                        repositoryTelefone.Excluir(telefoneModel);
                        MessageBox.Show("Registro excluido com sucesso!", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        btnPesquisar_Click(sender, e);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Erro ao excluir registro: " + ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                MessageBox.Show("Não há registro(s) para excluir!", "Informação!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Пример #2
0
        private async void GravarTelEnd(int Id, CadastrarUsuarioViewModel novousuario)
        {
            TelefoneRepository _telefone    = new TelefoneRepository();
            Telefone           NovoTelefone = new Telefone();

            NovoTelefone.Telefone1 = novousuario.Telefone;
            NovoTelefone.UsuarioId = Id;
            await _telefone.Gravar(NovoTelefone);

            EnderecoRepository _endereco    = new EnderecoRepository();
            Endereco           NovoEndereco = new Endereco();

            NovoEndereco.Cidade    = novousuario.Cidade;
            NovoEndereco.Cep       = novousuario.Cep;
            NovoEndereco.Endereco1 = novousuario.Endereco;
            NovoEndereco.Numero    = novousuario.Numero;
            NovoEndereco.UsuarioId = Id;
            await _endereco.Gravar(NovoEndereco);
        }
Пример #3
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            if (mkdTelefone.Text.Replace("_", "").Replace("(", "").Replace(")", "").Replace("-", "").Trim().Length < 10)
            {
                errorProvider1.SetError(mkdTelefone, "Telefone Inválido");
                return;
            }


            if (!string.IsNullOrEmpty(txtEmail.Text) && !Funcoes.validarEmail(txtEmail, errorProvider1))
            {
                return;
            }

            if (!string.IsNullOrEmpty(txtSite.Text) && !Funcoes.validarURL(txtSite, errorProvider1))
            {
                return;
            }
            try
            {
                TelefoneRepository repositoryTelefone = new TelefoneRepository();
                Telefone           telefoneModel      = new Telefone();

                telefoneModel.id_contato = Convert.ToInt32(cbxContato.SelectedValue);
                telefoneModel.email      = txtEmail.Text.Trim();
                telefoneModel.telefone   = mkdTelefone.Text.Trim();
                telefoneModel.site       = txtSite.Text.Trim();
                telefoneModel.tipo       = cbxTipo.Text;
                repositoryTelefone.Inserir(telefoneModel);
                Limpar();
                MessageBox.Show("Contato cadastrado com sucesso", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro ao cadastrar contato: " + ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public TelefoneController(TelefoneRepository telefoneRepo)
 {
     _telefoneRepo = telefoneRepo;
 }
Пример #5
0
 public ClienteController(ClienteRepository clienteRepo, EnderecoClienteRepository enderecoRepo, TelefoneRepository telefoneRepo)
 {
     _clienteRepo  = clienteRepo;
     _enderecoRepo = enderecoRepo;
     _telefoneRepo = telefoneRepo;
 }
Пример #6
0
        private void btnPesquisar_Click(object sender, EventArgs e)
        {
            TelefoneRepository repositoryTelefone = new TelefoneRepository();

            dgvPesquisaContato.DataSource = repositoryTelefone.retornarPorContato(Convert.ToInt32(cbxPesquisarContato.SelectedValue));
        }
Пример #7
0
        public async Task <ActionResult> Put(int id, [FromForm] AlterarUsuarioViewModel usuario)
        {
            bool ok = ValidaForm(usuario);

            if (ok == false)
            {
                return(NoContent());
            }

            // Verifica se existe o usuario no banco através do id passado por parametro
            var ExisteUsuario = await _repositorio.BuscarPorID(id);

            TelefoneRepository _tel = new TelefoneRepository();
            var Tel = await _tel.BuscaTelefone(id) != null ? await _tel.BuscaTelefone(id) : null;

            EnderecoRepository _end = new EnderecoRepository();
            var End = await _end.BuscaEndereco(id) != null ? await _end.BuscaEndereco(id) : null;

            //Se o Id do objeto não existir
            if (ExisteUsuario == null)
            {
                return(NotFound(
                           new
                {
                    Mensagem = "Usuário não encontrado.",
                    Erro = true
                }));
            }

            try {
                var UsuarioAlterado = VerificaAlteracao(ExisteUsuario, usuario);
                var user            = await _repositorio.Alterar(UsuarioAlterado);

                if (Tel != null)
                {
                    var TelefoneAlterado = VerificaAlteracaoTel(Tel, usuario);
                    var tel = await _tel.Alterar(TelefoneAlterado);
                }

                if (End != null)
                {
                    var EnderecoAlterado = VerificaAlteracaoEndereco(End, usuario);
                    var end = await _end.Alterar(EnderecoAlterado);
                }
            } catch (DbUpdateConcurrencyException) {
                //Verificamos se o objeto realmente existe no banco
                var usuario_valido = await _repositorio.BuscarPorID(id);

                if (usuario_valido == null)
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(
                       new
            {
                Mensagem = "Usuário alterado com sucesso.",
                Erro = false
            }
                       ));
        }
Пример #8
0
 public TelefoneService(TelefoneRepository tfRepository)
 {
     _tfRepository = tfRepository;
 }
Пример #9
0
 public TelefoneService(GlobalContext context)
 {
     Repository = new TelefoneRepository(context);
 }
Пример #10
0
 public TelefoneService()
 {
     Repository = new TelefoneRepository();
 }
Пример #11
0
 public TelefoneDomain(TelefoneRepository repository, SegurancaService segService)
 {
     _repository = repository;
     _segService = segService;
 }
 public TelefoneController()
 {
     _telefoneRepository = new TelefoneRepository();
 }