public bool DeleteStudentCourse(StudentCourse studentCourse) { if (lstStudentCourse.ContainsKey(studentCourse.GetHashKey())) { lstStudentCourse.Remove(studentCourse.GetHashKey()); return(true); } return(false); }
public void TC05_GetHashKey(string courseId, string StudentId, string term) { StudentCourse studentCourse = new StudentCourse(courseId, StudentId, term); string expected = String.Format("{0}_{1}_{2}", courseId.ToLower(), StudentId.ToLower(), term.ToLower()); Assert.AreEqual(expected, studentCourse.GetHashKey()); }
public bool AddStudentCourse(StudentCourse studentCourse) { if (lstStudentCourse.ContainsKey(studentCourse.GetHashKey())) { throw new ContainKeyException("Id has been existed!!"); } else { if (lstStudent.ContainsKey(studentCourse.StudentId) && lstCourse.ContainsKey(studentCourse.CourseId)) { lstStudentCourse.Add(studentCourse.GetHashKey(), studentCourse); return(true); } else { throw new StudentCourseException("Cannot add this studentCourse!!!"); } } }
public bool EditStudentCourse(StudentCourse studentCourse) { if (lstStudentCourse.ContainsKey(studentCourse.GetHashKey())) { lstStudentCourse[studentCourse.CourseId] = studentCourse; return(true); } else { throw new CannotUpdateStudentCourseException("Cannot Update this StudentCourse "); } }