public ActionResult Create(CmTeacher cmteacher) { if (ModelState.IsValid) { context.CmTeachers.Add(cmteacher); context.SaveChanges(); return RedirectToAction("Index"); } ViewBag.Possibleusers = context.Users; ViewBag.PossibleclUniversities = context.ClUniversities; return View(cmteacher); }
public ActionResult CreateTeacher(User user, string teacherTitle, int clUniversityId) { if (ModelState.IsValid) { context.Users.Add(user); CmTeacher newTeacher = new CmTeacher(); newTeacher.userID = user.ID;//TODO - probably newTeacher.clUniversityId = clUniversityId; if(teacherTitle.Equals("no")){ newTeacher.title = ""; } else { newTeacher.title = teacherTitle; } context.CmTeachers.Add(newTeacher); context.SaveChanges(); return RedirectToAction("Index"); } return View(user); }
public ActionResult Edit(CmTeacher cmteacher) { if (ModelState.IsValid) { context.Entry(cmteacher).State = EntityState.Modified; context.SaveChanges(); return RedirectToAction("Index"); } ViewBag.Possibleusers = context.Users; ViewBag.PossibleclUniversities = context.ClUniversities; return View(cmteacher); }