// // GET: /ClassList/Create public ActionResult Create() { Student student = new Student() { ClassID = 4 }; return View(student); }
public void DeleteStudent(Student student) { foreach (var presence in student.Presences) { entities.Presences.DeleteObject(presence); } entities.Students.DeleteObject(student); }
public ActionResult Create(FormCollection collection) { try { Student student = new Student(); if (TryUpdateModel(student)) { studentsRepository.AddStudent(student); studentsRepository.Save(); return RedirectToAction("Details", new { id = student.StudentID }); } return View(student); } catch { return View(); } }
// // Insert/Delete Methods public void AddStudent(Student student) { entities.Students.AddObject(student); }
/// <summary> /// Create a new Student object. /// </summary> /// <param name="studentID">Initial value of the StudentID property.</param> /// <param name="classID">Initial value of the ClassID property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="surname">Initial value of the Surname property.</param> public static Student CreateStudent(global::System.Int32 studentID, global::System.Int32 classID, global::System.String name, global::System.String surname) { Student student = new Student(); student.StudentID = studentID; student.ClassID = classID; student.Name = name; student.Surname = surname; return 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); }