public IActionResult Edit(int id, Professor professor) { if (!ModelState.IsValid) { var modalidades = _modalidadeService.FindAll(); var viewModel = new ProfessorViewModel { Professor = professor, Modalidades = modalidades }; return(View(viewModel)); } if (id != professor.Id) { return(BadRequest()); } try { _professorService.EditarProfessor(professor); return(RedirectToAction(nameof(Index))); } catch (NotFoundException) { return(NotFound()); } catch (DbConcurrencyException) { return(BadRequest()); } }
public ActionResult Edit([Bind(Include = "IdProfessor,NomeProfessor,Formacao,,Nome,Rua,Bairro,Cidade,UF")] Professor professor) { if (ModelState.IsValid) { int inst = sessao.RetornarID(); professor.instituicaoProfessor = inst; professorService.EditarProfessor(professor); return(RedirectToAction("Index")); } return(View(professor)); }