public async Task <IActionResult> Edit(long?id, [Bind("CursoID, NomeDoCurso, Descricao, Valor")] Curso curso) { if (id != curso.CursoID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(curso); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CursoExists(curso.CursoID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(curso)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Nascimento,CPF")] Professor professor) { if (id != professor.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(professor); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProfessorExists(professor.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(professor)); }
public async Task <IActionResult> Edit(long?id, [Bind("FuncionarioID, Nome, Cargo, Endereço")] Funcionario funcionario) { if (id != funcionario.FuncionarioID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(funcionario); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FuncionarioExists(funcionario.FuncionarioID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(funcionario)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Nascimento,NomeResponsavel,CPFResponsavel")] Aluno aluno) { if (id != aluno.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(aluno); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AlunoExists(aluno.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(aluno)); }
public async Task <IActionResult> Edit(int id, [Bind("Id, DataMatricula")] Matricula matricula, [Bind("IdTurma")] int IdTurma, [Bind("IdAluno")] int IdAluno) { if (id != matricula.Id) { return(NotFound()); } if (ModelState.IsValid) { try { matricula.Aluno = _context.Alunos.Where(a => a.Id == IdAluno).FirstOrDefault(); matricula.Turma = _context.Turmas.Where(t => t.Id == IdTurma).FirstOrDefault(); _context.Update(matricula); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MatriculaExists(matricula.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(matricula)); }
public async Task <IActionResult> Edit(int id, [Bind("Id, Sala")] Turma turma, [Bind("IdProfessor")] int IdProfessor) { if (id != turma.Id) { return(NotFound()); } if (ModelState.IsValid) { try { turma.Professor = _context.Professores.Where(p => p.Id == IdProfessor).FirstOrDefault(); _context.Update(turma); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProfessorExists(turma.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(turma)); }
public async Task <IActionResult> Edit(long?id, [Bind("AlunoID, Nome, NomeDaMae, Endereço")] Aluno aluno) { if (id != aluno.AlunoID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(aluno); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AlunoExists(aluno.AlunoID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(aluno)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Email,DataNascimento,DataCadastro,Matricula,Ativo")] Alunos alunos) { if (id != alunos.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(alunos); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AlunosExists(alunos.Id)) { return(NotFound()); } else { throw; } } TempData["UltimoAluno"] = $"{alunos.Id}- {alunos.Nome}"; ViewData["UltimoAluno"] = $"{alunos.Id}- {alunos.Nome}"; return(RedirectToAction(nameof(Index))); } return(View(alunos)); }