public async Task <IActionResult> Edit(int id, [Bind("Id,Nome")] Turma turma) { if (id != turma.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(turma); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TurmaExists(turma.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(turma)); }
public async Task UpdateAsync(Aluno obj) { bool hasAny = await _context.Aluno.AnyAsync(x => x.Id == obj.Id); if (!hasAny) { throw new NotFoundException("Id Not Found."); } try { _context.Update(obj); await _context.SaveChangesAsync(); } catch (DbConcurrencyException e) { throw new DbConcurrencyException(e.Message); } }