private void btn_ExcluirUsers_Click(object sender, EventArgs e)
 {
     try {
         ExcluirUsuario ex      = new ExcluirUsuario(Convert.ToInt32(textBox_id.Text));
         bool           retorno = ex.DeletUsers();
         if (retorno == true)
         {
             MessageBox.Show("Usuário Excluido com Sucesso!",
                             "Sucesso!!",
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
             textBox_id.Text            = string.Empty;
             textBox_nome.Text          = string.Empty;
             textBox_login.Text         = string.Empty;
             textBox_senha.Text         = string.Empty;
             textBox_email.Text         = string.Empty;
             textBox_matricula.Text     = string.Empty;
             textBox_id.Enabled         = false;
             textBox_nome.Enabled       = false;
             textBox_login.Enabled      = false;
             textBox_email.Enabled      = false;
             textBox_matricula.Enabled  = false;
             btn_AtualizarDados.Enabled = false;
             btn_Alterar.Enabled        = false;
             btn_CancelarEdit.Enabled   = false;
             btn_ExcluirUsers.Enabled   = false;
             btn_AddUserNovo.Enabled    = true;
             comboBox_permissao.Enabled = false;
         }
         else
         {
             MessageBox.Show("Exclusão NÃO realizada!",
                             "ERRO!",
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Warning);
             textBox_id.Text            = string.Empty;
             textBox_nome.Text          = string.Empty;
             textBox_login.Text         = string.Empty;
             textBox_senha.Text         = string.Empty;
             textBox_email.Text         = string.Empty;
             textBox_matricula.Text     = string.Empty;
             textBox_id.Enabled         = false;
             textBox_nome.Enabled       = false;
             textBox_login.Enabled      = false;
             textBox_email.Enabled      = false;
             textBox_matricula.Enabled  = false;
             btn_AtualizarDados.Enabled = false;
             btn_Alterar.Enabled        = false;
             btn_CancelarEdit.Enabled   = false;
             btn_ExcluirUsers.Enabled   = false;
             comboBox_permissao.Enabled = false;
         }
     }
     catch (TrataErros ex) {
         MessageBox.Show($"{ex.Message}", "ERRO!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> ExcluirUsuario([FromBody] ExcluirUsuario request)
        {
            try
            {
                var response = await _mediator.Send(request, CancellationToken.None);

                return(await ResponseAsync(response));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Ejemplo n.º 3
0
        public async Task <Response> Handle(ExcluirUsuario request, CancellationToken cancellationToken)
        {
            if (request == null)
            {
                return(new Response(false, "Identifique o usuário", request));
            }

            Usuario usuario = await _repositorioUsuario.CarregarObjetoPeloID(request.UsuarioId);

            if (usuario == null)
            {
                return(new Response(false, "Usuário não encontrado", usuario));
            }

            _repositorioUsuario.Remover(usuario);
            var result = new Response(true, "Usuário excluído com sucesso", null);

            return(await Task.FromResult(result));
        }