public void UpdateStudentSubjectState(int studentID, int subjectID) { StudentsSubjects studentSubject = context.StudentsSubjects.FirstOrDefault (ss => ss.SubjectID == subjectID && ss.StudentID == studentID); if (studentSubject == null) { studentSubject = new StudentsSubjects(); studentSubject.StudentID = studentID; studentSubject.SubjectID = subjectID; AddStudentSubject(studentSubject); } else { DeleteStudentSubject(studentSubject); } }
public void AddStudentSubject(StudentsSubjects ss) { context.Add(ss); context.SaveChanges(); }
public void DeleteStudentSubject(StudentsSubjects ss) { context.Remove(ss); context.SaveChanges(); }