public static List<Course> List(bool? availableInRegionalCampus = null)
        {
            List<Course> courseList = new List<Course>();

            SqlConnection cn = new SqlConnection(Database.ConnectionString);
            cn.Open();

            SqlCommand cm = cn.CreateCommand();
            cm.CommandType = CommandType.StoredProcedure;
            cm.CommandText = "GetCourseList";
            cm.Parameters.AddWithValue("@AvailableInRegionalCampus", availableInRegionalCampus);
            SqlDataReader dr = cm.ExecuteReader();

            while (dr.Read())
            {
                Course course = new Course();
                course.Id = Convert.ToInt32(dr["Course_ID"]);
                course.Prefix = dr["Course_Prefix"].ToString();
                course.Number = dr["Course_Number"].ToString();
                course.Section = dr["Course_Section"].ToString();
                course.Title = dr["Title"].ToString();
                course.Department = dr["Course_Department"].ToString();
                course.AvailableInRegionalCampus = Convert.ToBoolean(dr["availableInRegionalCampus"]);

                courseList.Add(course);
            }

            cn.Close();

            return courseList;
        }
        public static Course Get(int id)
        {
            SqlConnection cn = new SqlConnection(Database.ConnectionString);
            cn.Open();

            SqlCommand cm = cn.CreateCommand();
            cm.CommandType = CommandType.StoredProcedure;
            cm.CommandText = "GetCourse";
            cm.Parameters.AddWithValue("@Id", id);
            SqlDataReader dr = cm.ExecuteReader();

            dr.Read();

            Course course = new Course();
            course.Id = Convert.ToInt32(dr["Course_ID"]);
            course.Prefix = dr["Course_Prefix"].ToString();
            course.Number = dr["Course_Number"].ToString();
            course.Section = dr["Course_Section"].ToString();
            course.Title = dr["Title"].ToString();
            course.Department = dr["Course_Department"].ToString();
            course.AvailableInRegionalCampus = Convert.ToBoolean(dr["availableInRegionalCampus"]);

            cn.Close();

            return course;
        }
        public static List<Test> List(string nid)
        {
            List<Test> list = new List<Test>();

            SqlConnection cn = new SqlConnection(Database.ConnectionString);
            cn.Open();

            SqlCommand cm = cn.CreateCommand();
            cm.CommandType = CommandType.StoredProcedure;
            cm.CommandText = "GetAvailableTestList";
            cm.Parameters.AddWithValue("@NID", nid);
            SqlDataReader dr = cm.ExecuteReader();

            while (dr.Read())
            {
                Test test = new Test();
                test.Id = Convert.ToInt32(dr["Test_ID"]);
                test.Name = dr["Test_Name"].ToString();

                Course course = new Course();
                course.Prefix = dr["Course_Prefix"].ToString();
                course.Number = dr["Course_Number"].ToString();
                course.Title = dr["Title"].ToString();

                Professor professor = new Professor();
                professor.FirstName = dr["First_Name"].ToString();
                professor.LastName = dr["Last_Name"].ToString();
                course.Professor = professor;

                test.Course = course;

                list.Add(test);
            }

            cn.Close();

            return list;
        }
        public static List<Test> List(int? courseId = null, int? term = null, bool? active = null, bool? availableInRegionalCampus = null, string nid = null, DateTime? endDate = null)
        {
            List<Test> list = new List<Test>();

            SqlConnection cn = new SqlConnection(Database.ConnectionString);
            cn.Open();

            SqlCommand cm = cn.CreateCommand();
            cm.CommandType = CommandType.StoredProcedure;
            cm.CommandText = "GetTestList";
            cm.Parameters.AddWithValue("@CourseId", courseId);
            cm.Parameters.AddWithValue("@Term", term);
            cm.Parameters.AddWithValue("@Active", active);
            cm.Parameters.AddWithValue("@AvailableInRegionalCampus", availableInRegionalCampus);
            cm.Parameters.AddWithValue("@NID", nid);
            cm.Parameters.AddWithValue("@EndDate", endDate);
            SqlDataReader dr = cm.ExecuteReader();

            while (dr.Read())
            {
                Test test = new Test();
                test.Id = Convert.ToInt32(dr["Test_ID"]);
                test.Name = dr["Test_Name"].ToString();
                test.StartDate = Convert.ToDateTime(dr["Open_Date_Time"]);
                test.EndDate = Convert.ToDateTime(dr["Close_Date_Time"]);

                Course course = new Course();
                course.Id = Convert.ToInt32(dr["Course_ID"]);
                course.Prefix = dr["Course_Prefix"].ToString();
                course.Number = dr["Course_Number"].ToString();
                course.Title = dr["Title"].ToString();

                Professor professor = new Professor();
                professor.FirstName = dr["First_Name"].ToString();
                professor.LastName = dr["Last_Name"].ToString();
                course.Professor = professor;

                test.Course = course;

                list.Add(test);
            }

            cn.Close();

            return list;
        }
        public static Test Get(int id)
        {
            SqlConnection cn = new SqlConnection(Database.ConnectionString);
            cn.Open();

            SqlCommand cm = cn.CreateCommand();
            cm.CommandType = CommandType.StoredProcedure;
            cm.CommandText = "GetTest";
            cm.Parameters.AddWithValue("@Id", id);
            SqlDataReader dr = cm.ExecuteReader();

            dr.Read();

            Test test = new Test();
            test.Id = Convert.ToInt32(dr["Test_ID"]);
            test.Name = dr["Test_Name"].ToString();
            test.StartDate = Convert.ToDateTime(dr["Open_Date_Time"]);
            test.EndDate = Convert.ToDateTime(dr["Close_Date_Time"]);

            Course course = new Course();
            course.Id = Convert.ToInt32(dr["Course_ID"]);
            course.Prefix = dr["Course_Prefix"].ToString();
            course.Number = dr["Course_Number"].ToString();
            course.Title = dr["Title"].ToString();

            Professor professor = new Professor();
            professor.FirstName = dr["First_Name"].ToString();
            professor.LastName = dr["Last_Name"].ToString();
            course.Professor = professor;

            test.Course = course;

            cn.Close();

            return test;
        }