Exemple #1
0
        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);
        }
Exemple #2
0
 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);
 }
Exemple #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Students EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToStudents(Student student)
 {
     base.AddObject("Students", student);
 }
Exemple #4
0
 /// <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;
 }