コード例 #1
0
 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));
 }
コード例 #2
0
        // 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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
 // 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());
 }