Beispiel #1
0
        public ActionResult Create(Teaching teaching)
        {
            if (ModelState.IsValid)
            {
                db.Teachings.Add(teaching);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.ProfessorID = new SelectList(db.Professors, "ProfessorID", "FirstName", teaching.ProfessorID);
            ViewBag.CourseID = new SelectList(db.Courses, "CourseID", "Name", teaching.CourseID);
            return View(teaching);
        }
Beispiel #2
0
 public ActionResult Edit(Teaching teaching)
 {
     if (ModelState.IsValid)
     {
         db.Entry(teaching).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.ProfessorID = new SelectList(db.Professors, "ProfessorID", "FirstName", teaching.ProfessorID);
     ViewBag.CourseID = new SelectList(db.Courses, "CourseID", "Name", teaching.CourseID);
     return View(teaching);
 }