public ActionResult Create(Student student) { if (ModelState.IsValid) { db.Students.AddObject(student); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ParentID = new SelectList(db.Parents, "ParentID", "First_Name", student.ParentID); return View(student); }
public ActionResult Edit(Student student) { if (ModelState.IsValid) { db.Students.Attach(student); db.ObjectStateManager.ChangeObjectState(student, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ParentID = new SelectList(db.Parents, "ParentID", "First_Name", student.ParentID); return View(student); }
/// <summary> /// Deprecated Method for adding a new object to the Students EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToStudents(Student student) { base.AddObject("Students", student); }
/// <summary> /// Create a new Student object. /// </summary> /// <param name="studentID">Initial value of the StudentID property.</param> /// <param name="first_Name">Initial value of the First_Name property.</param> /// <param name="last_Name">Initial value of the Last_Name property.</param> public static Student CreateStudent(global::System.Int32 studentID, global::System.String first_Name, global::System.String last_Name) { Student student = new Student(); student.StudentID = studentID; student.First_Name = first_Name; student.Last_Name = last_Name; return student; }