public ActionResult Edit([Bind(Include = "id,Alumno_id,Curso_id,Nota")] AlumnoCurso alumnoCurso) { if (ModelState.IsValid) { db.Entry(alumnoCurso).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Alumno_id = new SelectList(CombosHelpers.GetAlumnos(), "id", "Nombre", alumnoCurso.Alumno_id); ViewBag.Curso_id = new SelectList(CombosHelpers.GetCursos(), "id", "Nombre", alumnoCurso.Curso_id); return(View(alumnoCurso)); }
// GET: AlumnoCursoes/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AlumnoCurso alumnoCurso = db.AlumnoCurso.Find(id); if (alumnoCurso == null) { return(HttpNotFound()); } ViewBag.Alumno_id = new SelectList(CombosHelpers.GetAlumnos(), "id", "Nombre", alumnoCurso.Alumno_id); ViewBag.Curso_id = new SelectList(CombosHelpers.GetCursos(), "id", "Nombre", alumnoCurso.Curso_id); return(View(alumnoCurso)); }
public ActionResult Create([Bind(Include = "id,Alumno_id,Curso_id,Nota")] AlumnoCurso alumnoCurso) { if (ModelState.IsValid) { db.AlumnoCurso.Add(alumnoCurso); try { db.SaveChanges(); } catch (Exception ex) { ex.ToString(); ModelState.AddModelError(string.Empty, "Error"); } return(RedirectToAction("Index")); } ViewBag.Alumno_id = new SelectList(CombosHelpers.GetAlumnos(), "id", "Nombre", alumnoCurso.Alumno_id); ViewBag.Curso_id = new SelectList(CombosHelpers.GetCursos(), "id", "Nombre", alumnoCurso.Curso_id); return(View(alumnoCurso)); }
// GET: AlumnoCursoes/Create public ActionResult Create() { ViewBag.Alumno_id = new SelectList(CombosHelpers.GetAlumnos(), "id", "Nombre"); ViewBag.Curso_id = new SelectList(CombosHelpers.GetCursos(), "id", "Nombre"); return(View()); }