public ActionResult Create(Modulo modulo) { if (ModelState.IsValid) { Repositorio.Incluir(modulo); return RedirectToAction("Index"); } ViewBag.ProfessorID = new SelectList(TodosProfessoresEnumerable(), "Id", "Nome", modulo.ProfessorID); ViewBag.CursoID = new SelectList(TodosCursosEnumerable(), "Id", "Nome", modulo.CursoID); return View(modulo); }
public ActionResult Edit(Modulo modulo) { ModelState["Professor"].Errors.Clear(); ModelState["Curso"].Errors.Clear(); if (ModelState.IsValid) { Repositorio.Atualizar(modulo); return RedirectToAction("Index"); } ViewBag.ProfessorID = new SelectList(TodosProfessoresEnumerable(), "Id", "Nome", modulo.ProfessorID); ViewBag.CursoID = new SelectList(TodosCursosEnumerable(), "Id", "Nome", modulo.CursoID); return View(modulo); }