public static bool UnregisterCourse(int studentID, string course) { bool result = false; try { if (RepositoryStudent.DoesStudentExists(studentID)) { if (RepositoryStudent.WasStudentRegisteredForCourse(studentID, course)) { if (!RepositoryStudent.HasStudentAlreadyCompletedCourse(studentID, course)) { result = RepositoryStudent.UnRegisterCourse(studentID, course); } else { throw new Exception("Student is already graded for this course."); } } else { throw new Exception("Student was not enrolled for this course."); } } else { throw new Exception("Student is not registered......."); } } catch (Exception) { throw; } return(result); }
public static bool RegisterCourse(int StudentID, string semester, string course) { bool result = false; try { if (RepositoryStudent.DoesStudentExists(StudentID)) { if (RepositoryStudent.HasStudentTakenPreRequisites(StudentID, course, 2.0f)) { if (RepositoryCourse.IsVacancyThereInCourse(course, semester)) { result = RepositoryStudent.RegisterCourse(StudentID, semester, course); } else { throw new Exception("Course capacity exceeded.."); } } else { throw new Exception("Missing Prerequisite for " + course); } } else { throw new Exception("Student with ID: " + StudentID + " not registered"); } } catch (Exception) { throw; } return(result); }