public static void UpdateStudentCourse(int studentCourseId, int studentId, int courseId, int mark) { bool submitChange = false; //update a student course StudentCourse studentCourse = db.StudentCourses.Single(sc => sc.Id.Equals(studentCourseId)); if (studentCourse.studentId != studentId) { studentCourse.studentId = studentId; submitChange = true; } if (studentCourse.courseId != courseId) { studentCourse.courseId = courseId; submitChange = true; } if (studentCourse.finalGrade != mark) { studentCourse.finalGrade = mark; submitChange = true; } if (submitChange) { db.SubmitChanges(); } }
public static void DeleteStudentCourse(int studentCourseId) { //delete a student course by setting its isDeleted flag to 1 StudentCourse studentCourse = db.StudentCourses.Single(sc => sc.Id.Equals(studentCourseId)); studentCourse.isDeleted = 1; db.SubmitChanges(); }
public static void AddStudentCourse(int studentId, int courseId, int mark) { //add a new student course record by suppling the student id, course id and mark StudentCourse studentCourse = new StudentCourse(); studentCourse.studentId = studentId; studentCourse.courseId = courseId; studentCourse.finalGrade = mark; db.StudentCourses.InsertOnSubmit(studentCourse); db.SubmitChanges(); }
partial void DeleteStudentCourse(StudentCourse instance);
partial void UpdateStudentCourse(StudentCourse instance);
partial void InsertStudentCourse(StudentCourse instance);