public IHttpActionResult Atualizar(int id, [FromBody] AlunoDTO aluno)
        {
            try
            {
                AlunoModel _aluno = new AlunoModel();

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

                if (alunoExiste == null)
                {
                    return(NotFound());
                }
                else
                {
                    aluno.id = id;
                    _aluno.Atualizar(aluno);

                    return(Ok(_aluno.ListarAlunos(id)));
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #2
0
 public IHttpActionResult Put(int id, [FromBody] AlunoDTO alunoDTO)
 {
     try
     {
         AlunoModel aluno = new AlunoModel();
         aluno.Atualizar(id, alunoDTO);
         return(Ok(aluno.ListarAlunos(id).FirstOrDefault()));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
예제 #3
0
        [HttpPut]//[FromBody]
        public IHttpActionResult Put(AlunoDTO aluno)
        {
            try
            {
                AlunoModel _aluno = new AlunoModel();
                _aluno.Atualizar(aluno);

                return(Ok(aluno));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #4
0
        public IHttpActionResult Put(int id, [FromBody] AlunoDTO aluno)
        {
            try
            {
                aluno.id = id;
                _aluno.Atualizar(aluno);

                return(Ok(_aluno.ListarAlunos(id).FirstOrDefault()));
            }
            catch (Exception e)
            {
                return(InternalServerError(e));
            }
        }
예제 #5
0
        public IHttpActionResult Put(int id, [FromBody] Aluno aluno)
        {
            try
            {
                var _aluno = new AlunoModel();
                aluno.id = id;
                _aluno.Atualizar(aluno);

                return(Ok(_aluno.ListarAluno(id).FirstOrDefault()));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
        public IHttpActionResult Put(int id, AlunoDTO _aluno)
        {
            AlunoDTO alu = new AlunoDTO();

            try
            {
                _aluno.id = id;
                aluno.Atualizar(_aluno);
                //VAI RETORNAR O RETORNO DO MÉTODO Atualizar();

                return(Ok(aluno.ListarAluno(id).FirstOrDefault()));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #7
0
        public IHttpActionResult Put(int id, [FromBody] AlunoDTO aluno)
        {
            try
            {
                AlunoModel _aluno = new AlunoModel();

                if (id == aluno.Id)
                {
                    _aluno.Atualizar(aluno);
                }
                else
                {
                    return(Ok("Chave do aluno não compativel"));
                }

                return(Ok("Atualizado com sucesso"));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }