Exemple #1
0
        public async Task <IActionResult> AlteracaoAluno(int id, Aluno aluno)
        {
            if (id != aluno.IdAluno)
            {
                return(BadRequest());
            }

            _context.Entry(aluno).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                return(CreatedAtAction("GetAluno", new { id = aluno.IdAluno }, aluno));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AlunoExists(id))
                {
                    ModelState.AddModelError(string.Empty, "Aluno não encontrado!");
                    return(NotFound(ModelState));
                }
            }

            return(NoContent());
        }