public ActionResult AddStudentPost(FormCollection frmcollection) { objstudent = new Student(); objstudent.StudentName = frmcollection["StudentName"]; objstudent.Standard = GetStandardById(int.Parse(frmcollection["StandardId"])); lstcourse = GetAllCourses(); foreach (Cours crs in lstcourse) { if ((frmcollection[crs.CourseName]).ToString().Contains("true")) { objstudent.Courses.Add(GetCourseByName(crs.CourseName)); } } DB.Students.AddObject(objstudent); DB.SaveChanges(); return RedirectToAction("Index"); }
/// <summary> /// Create a new Student object. /// </summary> /// <param name="studentId">Initial value of the StudentId property.</param> public static Student CreateStudent(global::System.Int32 studentId) { Student student = new Student(); student.StudentId = studentId; 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); }