Exemple #1
0
  public bool IsLastQuestion(Question question)
  {
      if (!Questions.Contains(question))
          throw new InvalidOperationException("The passed question is not in the list of questions for this quiz.");
 
      return Questions.OrderByDescending(q => q.Order).Take(1).Single() == question;
  }
        private Question GetQuestion(IDataReader reader)
        {
            int questionID = reader.GetInt32(reader.GetOrdinal("QuestionID"));

            string answerQuery = @"
                SELECT	[AnswerID], [Text], [Correct]
                FROM	[dbo].[Answer]
                WHERE	[QuestionID] = @QuestionID 
                ";

            IList<Answer> answers =
                DBHelper.ExecuteReader<IList<Answer>>(new SqlConnection(DBHelper.ConnectionString), new SqlCommand(answerQuery), LoadAnswers,
                    new SqlParameter() { ParameterName = "@QuestionID", DbType = DbType.Int32, Value = questionID });

            Question question =
                new Question(
                    reader.GetString(reader.GetOrdinal("Text")),
                    reader.GetInt32(reader.GetOrdinal("PresentationOrder")),
                    answers);

            _IdsByHashCode.Add(question.GetHashCode(), questionID);
            return question;
        }