Example #1
0
        public long NextQuestionId(Question question, IDbConnection db)
        {
            if (null == question)
                return 0;

            return db.QueryScalar<long>(@"SELECT TOP 1 Id FROM Question WHERE [Order] > @order AND SegmentId = @segmentId", new { order = question.Order, segmentId = question.SegmentId });
        }
Example #2
0
 public bool Delete(Question Question)
 {
     using (IDbConnection db = _factory.OpenDbConnection())
     {
         db.Delete<Question>(Question);
         return true;
     }
 }
Example #3
0
        public Question Add(Question Question)
        {
            using (IDbConnection db = _factory.OpenDbConnection())
            {
                db.Insert<Question>(Question);

                Question.Id = db.GetLastInsertId();

                return Question;
            }
        }
Example #4
0
 public QuestionAnswer(Question question)
 {
     this.QuestionId = question.Id;
 }
Example #5
0
 public Question Update(Question Question)
 {
     using (IDbConnection db = _factory.OpenDbConnection())
     {
         db.Update<Question>(Question);
         return Question;
     }
 }
Example #6
0
 private Question PopulateDerived(Question question, IDbConnection db)
 {
     question.Answers = Answers(question, db);
     question.NextId = NextQuestionId(question, db);
     return question;
 }
Example #7
0
        private List<Answer> Answers(Question question, IDbConnection db)
        {
            if (null == question)
                return new List<Answer>();

            return db.Where<Answer>(a => a.QuestionId == question.Id).OrderBy(a => a.Order).ThenBy(a => a.Id).ToList();
        }