public ActionResult Create([Bind(Include = "TeacherId,LastName,FirstName,Major,Department, Course")] Instructor postInstructor) { if (ModelState.IsValid) { SchoolSystem.DbModels.Model.Instructor t = new SchoolSystem.DbModels.Model.Instructor { FirstName = postInstructor.FirstName, LastName = postInstructor.LastName, HireDate = DateTime.Now, Major = postInstructor.Major, DepartmentId = int.Parse(postInstructor.Department), InstructorId = postInstructor.TeacherId, CourseId = int.Parse(postInstructor.Course) }; db.teachers.Add(t); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(postInstructor)); }
public ActionResult Edit([Bind(Include = "TeacherId,LastName,FirstName,HireDate,Major,Department,Course")] Instructor instructor) { SchoolSystem.DbModels.Model.Instructor instructorToEdit = new SchoolSystem.DbModels.Model.Instructor { InstructorId = instructor.TeacherId, FirstName = instructor.FirstName, LastName = instructor.LastName, Major = instructor.Major, HireDate = instructor.HireDate, DepartmentId = int.Parse(instructor.Department), CourseId = int.Parse(instructor.Course) }; if (ModelState.IsValid) { db.Entry(instructorToEdit).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(instructor)); }