public ActionResult Create(SchoolClass schoolClass) { if (ModelState.IsValid) { _schoolClassDbContext.dbSet.Add(schoolClass); _schoolClassDbContext.SaveChanges(); return RedirectToAction("Index"); } return View(schoolClass); }
public ActionResult AddClass(SchoolClass classs, string schoolName) { if (ModelState.IsValid) { classs.schoolId = _schoolDb.getSchoolIdByName(schoolName); _schoolClassDbContext.dbSet.Add(classs); _schoolClassDbContext.SaveChanges(); return RedirectToAction("Index"); } // If we got this far, something failed, redisplay form return View(classs); }
public ActionResult Edit(SchoolClass classs, string schoolName) { if (ModelState.IsValid) { classs.schoolId = _schoolDb.getSchoolIdByName(schoolName); _schoolClassDbContext.Entry(classs).State = EntityState.Modified; _schoolClassDbContext.SaveChanges(); return RedirectToAction("Index"); } return View(classs); }