Exemplo n.º 1
0
 public IActionResult Excluir([FromBody] int id)
 {
     try {
         _alunoRepository.Excluir(id);
         return(Ok(new { msg = "Excluído com sucesso." }));
     } catch (Exception) {
         return(new StatusCodeResult(412)); // Pré-condição falhou, pois provavelmente esse registro há relacionamentos que o impedem de ser excluído.
     }
 }
Exemplo n.º 2
0
 public IActionResult Delete(int id)
 {
     try
     {
         _repo.Excluir(id);
         return(Ok(_repo.SelecionarTudo()));
     }
     catch (System.Exception)
     {
         return(StatusCode(500));
     }
 }
Exemplo n.º 3
0
        public void Excluir(int id)
        {
            var alunoExistente = repository.ObterPorId(id);

            if (alunoExistente != null)
            {
                repository.Excluir(id);
            }
            else
            {
                AddNotification("aluno", "Não é possivel excluir um aluno que não existe.");
            }
        }
Exemplo n.º 4
0
        public IActionResult Delete(int id)
        {
            try
            {
                _repoAluno.Excluir(id);
                List <Aluno> alunos = _repoAluno.SelecionarTudo();

                return(Ok(_mapper.Map <IEnumerable <AlunoDto> >(alunos)));
            }
            catch (System.Exception)
            {
                return(StatusCode(500));
            }
        }
Exemplo n.º 5
0
        public string Excluir(int idAluno)
        {
            try
            {
                Aluno aluno = ObterPorId(idAluno);
                AlunoRepository.Excluir(aluno);
                //Executa as ações
                AlunoRepository.SalvarAlteracoes();

                return(null);
            }
            catch (Exception ex)
            {
                return("Erro: " + ex.Message);
            }
        }
Exemplo n.º 6
0
 public void Excluir(int id)
 {
     _AlunoRepository.Excluir(id);
 }
Exemplo n.º 7
0
 public IEnumerable <Aluno> Delete(int id)
 {
     _repo.Excluir(id);
     return(_repo.SelecionarTudo());
 }
Exemplo n.º 8
0
 public void Delete(int id)
 {
     _repo.Excluir(id);
 }