Ejemplo n.º 1
0
        /// <summary>
        /// Delete a Course from the database
        /// </summary>
        /// <param name="theCourse">a Course object to delete from the Database</param>
        public void DeleteCourse(CourseData theCourse)
        {
            QuizEntity temp = new QuizEntity();

            List <QuizData> quizzes = temp.ReadQuizzes(theCourse);

            for (int i = 0; i < quizzes.Count; i++)
            {
                temp.DeleteQuiz(quizzes[i]);
            }

            if (DataReader != null)
            {
                DataReader.Close();
            }

            SQL = "DELETE FROM `courses` WHERE `courses`.`course_id` = \"" + theCourse.Id + "\";";

            InitializeCommand();
            OpenConnection();

            int result = ExecuteStoredProcedure();

            CloseConnection();

            if (result == 0)
            {
                throw new Exception("Could not delete Course from the database");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Delete a Course from the database
        /// </summary>
        /// <param name="theCourse">a Course object to delete from the Database</param>
        public void DeleteCourse(CourseData theCourse)
        {
            QuizEntity temp = new QuizEntity();

            List<QuizData> quizzes = temp.ReadQuizzes(theCourse);

            for (int i = 0; i < quizzes.Count; i++)
                temp.DeleteQuiz(quizzes[i]);

            if (DataReader != null)
                DataReader.Close();

            SQL = "DELETE FROM `courses` WHERE `courses`.`course_id` = \"" + theCourse.Id + "\";";

            InitializeCommand();
            OpenConnection();

            int result = ExecuteStoredProcedure();

            CloseConnection();

            if (result == 0)
                throw new Exception("Could not delete Course from the database");
        }