public ActionResult Create([Bind(Include = "ID,LastName,FirstMidName,HireDate")] Driver driver) { if (ModelState.IsValid) { db.Drivers.Add(driver); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(driver)); }
public ActionResult Create([Bind(Include = "TrackID,TrackName,TrackLocation")] Track track) { if (ModelState.IsValid) { db.Tracks.Add(track); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(track)); }
public ActionResult Create([Bind(Include = "ID,LastName,FirstMidName,HireDate")] Teacher teacher) { if (ModelState.IsValid) { db.Teachers.Add(teacher); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID = new SelectList(db.LocationAssignments, "TeacherID", "Location", teacher.ID); return(View(teacher)); }
public ActionResult Create([Bind(Include = "CompanyID,CompanyName,CompanyLocation,StartDate,TeacherID")] Company company) { if (ModelState.IsValid) { db.Companies.Add(company); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TeacherID = new SelectList(db.Teachers, "ID", "LastName", company.TeacherID); return(View(company)); }
public ActionResult Create([Bind(Include = "CarYear, CarMake, CarName, CarDescription")] Car car) { try { if (ModelState.IsValid) { db.Cars.Add(car); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DataException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(car)); }