public IHttpActionResult Delete(int id)
 {
     try
     {
         aluno.Deletar(id);
         return(Ok("Deletado com sucesso"));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
예제 #2
0
 public IHttpActionResult Delete(int id)
 {
     try
     {
         AlunoModel _aluno = new AlunoModel();
         _aluno.Deletar(id);
         return(Ok("Deletado com Sucesso!"));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
        public IHttpActionResult Deletar(int id)
        {
            try
            {
                AlunoModel _aluno = new AlunoModel();

                var aluno = _aluno.ListarAlunos().FirstOrDefault(a => a.id == id);

                if (aluno == null)
                {
                    return(NotFound());
                }
                else
                {
                    _aluno.Deletar(id);
                    return(Ok("Deletado com sucesso."));
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }