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 }); }
public bool Delete(Question Question) { using (IDbConnection db = _factory.OpenDbConnection()) { db.Delete<Question>(Question); return true; } }
public Question Add(Question Question) { using (IDbConnection db = _factory.OpenDbConnection()) { db.Insert<Question>(Question); Question.Id = db.GetLastInsertId(); return Question; } }
public QuestionAnswer(Question question) { this.QuestionId = question.Id; }
public Question Update(Question Question) { using (IDbConnection db = _factory.OpenDbConnection()) { db.Update<Question>(Question); return Question; } }
private Question PopulateDerived(Question question, IDbConnection db) { question.Answers = Answers(question, db); question.NextId = NextQuestionId(question, db); return question; }
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(); }