Exemplo n.º 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 });
        }
Exemplo n.º 2
0
 public bool Delete(Question Question)
 {
     using (IDbConnection db = _factory.OpenDbConnection())
     {
         db.Delete<Question>(Question);
         return true;
     }
 }
Exemplo n.º 3
0
        public Question Add(Question Question)
        {
            using (IDbConnection db = _factory.OpenDbConnection())
            {
                db.Insert<Question>(Question);

                Question.Id = db.GetLastInsertId();

                return Question;
            }
        }
Exemplo n.º 4
0
 public QuestionAnswer(Question question)
 {
     this.QuestionId = question.Id;
 }
Exemplo n.º 5
0
 public Question Update(Question Question)
 {
     using (IDbConnection db = _factory.OpenDbConnection())
     {
         db.Update<Question>(Question);
         return Question;
     }
 }
Exemplo n.º 6
0
 private Question PopulateDerived(Question question, IDbConnection db)
 {
     question.Answers = Answers(question, db);
     question.NextId = NextQuestionId(question, db);
     return question;
 }
Exemplo n.º 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();
        }