public async Task Update(Escola escola) { _context.Entry(escola).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch { if (EscolaExiste(escola.Id)) { throw; } else { throw new Exception("Escola não existe."); } } }
public async Task Update(Turma turma) { _context.Entry(turma).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch { if (TurmaExists(turma.Id) && EscolaExists(turma.EscolaId)) { throw; } else { throw new Exception("Turma ou escola não existe.");; } } }