private void addStudentCommit(TutorMaster.StudentCommitment studentCommit) //add a student commitment { TutorMasterDBEntities4 db = new TutorMasterDBEntities4(); db.StudentCommitments.AddObject(studentCommit); db.SaveChanges(); }
private void add15Block(DateTime begin, bool weekly) { int lastCR = getNextCmtId(); //last commit row int lastSCR = getNextStdCmtKey(); //last student commit row //add the first student committment and comittment in case the commitment is not weekly TutorMaster.Commitment newCommit = new TutorMaster.Commitment(); newCommit.CmtID = lastCR; newCommit.Class = "-"; newCommit.Location = "-"; newCommit.Tutoring = false; newCommit.StartTime = begin; newCommit.Open = true; newCommit.Weekly = weekly; newCommit.ID = -1; addCommit(newCommit); TutorMaster.StudentCommitment newStudentCommit = new TutorMaster.StudentCommitment(); newStudentCommit.CmtID = lastCR; newStudentCommit.ID = id; newStudentCommit.Key = lastSCR; addStudentCommit(newStudentCommit); DateTime endOfSemester = new DateTime(2017, 6, 1, 0, 0, 0); //if it is weekly, keep going 7 days into future and if it is before end of semster, add the new commitment if (weekly) { while (begin.AddDays(7).CompareTo(endOfSemester) < 0) { begin = begin.AddDays(7); lastSCR += 1; lastCR += 1; //add the commitment first and then add the student commitment TutorMaster.Commitment newCommitW = new TutorMaster.Commitment(); newCommitW.CmtID = lastCR; newCommitW.Class = "-"; newCommitW.Location = "-"; newCommitW.Tutoring = false; newCommitW.StartTime = begin; newCommitW.Open = true; newCommitW.Weekly = weekly; newCommitW.ID = -1; addCommit(newCommitW); //add the student commitment weekly TutorMaster.StudentCommitment newStudentCommitW = new TutorMaster.StudentCommitment(); newStudentCommitW.CmtID = lastCR; newStudentCommitW.ID = id; newStudentCommitW.Key = lastSCR; addStudentCommit(newStudentCommitW); } } }