예제 #1
0
        private QuestionModel ParseQuestionFromReader(SqlDataReader reader)
        {
            QuestionModel question = new QuestionModel();

            question.ExerciseId     = (int)reader["EX_ID"];
            question.QuestionId     = (int)reader["EXQ_ID"];
            question.Instructions   = (string)reader["EXQ_INSTRUCTIONS_TEMPLATE"];
            question.AnswerTemplate = (string)reader["EXQ_ANSWERS_TEMPLATE"];
            question.Order          = (int)reader["EXQ_ORDER"];
            question.Description    = (string)reader["EXQ_DESCRIPTION"];
            question.Hint           = reader["EXQ_HINT"] == DBNull.Value ? "No hint available" : (string)reader["EXQ_HINT"];
            if (DAHelpers.HasColumn(reader, "Answered"))
            {
                question.Answered = (Boolean)reader["Answered"];
            }
            if (DAHelpers.HasColumn(reader, "AnsweredDate"))
            {
                object sqlDateTime = reader["AnsweredDate"];
                question.AnsweredDate = (sqlDateTime == System.DBNull.Value)
                                        ? (DateTime?)null
                                        : Convert.ToDateTime(sqlDateTime);
            }
            question.StartingSql            = DAHelpers.StringFromReader(reader, "EXQ_STARTING_SQL");
            question.ExerciseQuestionIdGuid = (Guid)reader["EXQ_ID_GUID"];
            question.CreatedDate            = DAHelpers.DateTimeFromReader(reader, "EXQ_CREATED_DATE");
            question.CreatedBy            = DAHelpers.StringFromReader(reader, "EXQ_CREATED_BY");
            question.UpdatedDate          = DAHelpers.NullableDateTimeFromReader(reader, "EXQ_UPDATED_DATE");
            question.UpdatedBy            = DAHelpers.NullableStringFromReader(reader, "EXQ_UPDATED_BY");
            question.ExerciseQuestionType = (int)reader["EXQ_TYPE"];
            return(question);
        }
예제 #2
0
        private ExerciseModel ParseExerciseFromReader(SqlDataReader reader)
        {
            ExerciseModel exercise = new ExerciseModel();

            exercise.Summary          = (String)reader["EX_SUMMARY"];
            exercise.Name             = (String)reader["EX_NAME"];
            exercise.Description      = (String)reader["EX_DESCRIPTION"];
            exercise.ExerciseId       = (int)reader["EX_ID"];
            exercise.DataSourceId     = (int)reader["DS_ID"];
            exercise.Published        = DAHelpers.BooleanFromReader(reader, "EX_PUBLISHED");
            exercise.PublishedDate    = DAHelpers.DateTimeFromReader(reader, "EX_PUBLISHED_DATE");
            exercise.SectionName      = (String)reader["EX_SECTION_NAME"];
            exercise.Order            = (int)reader["EX_ORDER"];
            exercise.ShowQueryBuilder = DAHelpers.BooleanFromReader(reader, "EX_SHOW_QUERY_BUILDER");
            exercise.ExerciseIdGuid   = (Guid)reader["EX_ID_GUID"];
            exercise.CreatedDate      = DAHelpers.DateTimeFromReader(reader, "EX_CREATED_DATE");
            exercise.CreatedBy        = DAHelpers.StringFromReader(reader, "EX_CREATED_BY");
            exercise.UpdatedDate      = DAHelpers.NullableDateTimeFromReader(reader, "EX_UPDATED_DATE");
            exercise.UpdatedBy        = DAHelpers.NullableStringFromReader(reader, "EX_UPDATED_BY");

            return(exercise);
        }