コード例 #1
0
 //
 // GET: /ClassList/Create
 public ActionResult Create()
 {
     Student student = new Student()
     {
         ClassID = 4
     };
     return View(student);
 }
コード例 #2
0
 public void DeleteStudent(Student student)
 {
     foreach (var presence in student.Presences)
     {
         entities.Presences.DeleteObject(presence);
     }
     entities.Students.DeleteObject(student);
 }
コード例 #3
0
 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();
     }
 }
コード例 #4
0
 //
 // Insert/Delete Methods
 public void AddStudent(Student student)
 {
     entities.Students.AddObject(student);
 }
コード例 #5
0
 /// <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;
 }
コード例 #6
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);
 }