Example #1
0
 public IActionResult Excluir([FromBody] int id)
 {
     try {
         _professorRepository.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.
     }
 }
 public IActionResult Delete(int id)
 {
     try
     {
         _repo.Excluir(id);
         return(Ok(_repo.SelecionarTudo()));
     }
     catch (System.Exception)
     {
         return(StatusCode(500));
     }
 }
Example #3
0
 public IActionResult Delete(int id)
 {
     try
     {
         _repo.Excluir(id);
         List <Professor> professores = _repo.SelecionarTudo();
         return(Ok(_mapper.Map <IEnumerable <ProfessorDto> >(professores)));
     }
     catch (System.Exception)
     {
         return(StatusCode(500));
     }
 }
Example #4
0
        public string Excluir(int idProfessor)
        {
            try
            {
                Professor professor = ObterPorId(idProfessor);
                ProfessorRepository.Excluir(professor);
                //Executa as ações
                ProfessorRepository.SalvarAlteracoes();

                return(null);
            }catch (Exception ex)
            {
                return("Erro: " + ex.Message);
            }
        }
Example #5
0
 public IEnumerable <Professor> Delete(int id)
 {
     _repo.Excluir(id);
     return(_repo.SelecionarTudo());
 }