public void Atualizar(Aluno aluno) { var entry = _db.Entry(aluno); _db.Set <Aluno>().Attach(aluno); entry.State = EntityState.Modified; }
public async Task <IActionResult> PutAluno(long id, Aluno aluno) { if (id != aluno.Id) { return(BadRequest()); } _context.Entry(aluno).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AlunoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public Alunos Update(Alunos alunos) { if (!Exists(alunos.Id)) { return(new Alunos()); } var result = _contexto.Alunoss.SingleOrDefault(p => p.Id.Equals(alunos.Id)); if (result != null) { try { _contexto.Entry(result).CurrentValues.SetValues(alunos); _contexto.SaveChanges(); } catch (Exception) { throw; } } return(alunos); }