Exemple #1
0
        public List <QuestionABC> GetAllQuestionsBySubThemeName(string subThemeName)
        {
            List <QuestionABC> questions = new List <QuestionABC>();
            QuestionABC        quest     = new QuestionABC();
            AnswerDAL          aDAL      = new AnswerDAL();

            base.OpenConnection();

            SqlCommand command = new SqlCommand(string.Format("Select * from Questions inner join Sub_Themes on Questions.ID_SubTheme = Sub_Themes.ID where Sub_Themes.Sub_Theme like '" + "{0}" + "'", subThemeName), base._sqlConnection);

            SqlDataReader reader = command.ExecuteReader();

            using (reader)
            {
                while (reader.Read())
                {
                    quest.Id = (int)reader["ID"];
                    quest.QuestionCurrent = (string)reader["Question"];
                    quest.SubThemeId      = (int)reader["ID_SubTheme"];
                    quest.ListAnswers     = aDAL.GetAllAnswersByQuestion(quest.QuestionCurrent);

                    questions.Add(quest);

                    quest = new QuestionABC();
                }
            }

            base.CloseConnection();

            return(questions);
        }
Exemple #2
0
        public QuestionABC(int id, string question, int subThemeId)
        {
            AnswerDAL aDAL = new AnswerDAL();

            this._id         = id;
            this._question   = question;
            this._subThemeId = subThemeId;
            this._answers    = aDAL.GetAllAnswersByQuestion(question);
        }