예제 #1
0
 public bool Delete(Segment segment)
 {
     using (IDbConnection db = _factory.OpenDbConnection())
     {
         db.Delete<Segment>(segment);
         return true;
     }
 }
예제 #2
0
        public Segment Add(Segment segment)
        {
            using (IDbConnection db = _factory.OpenDbConnection())
            {
                db.Insert<Segment>(segment);

                segment.Id = db.GetLastInsertId();

                return segment;
            }
        }
예제 #3
0
 public Segment Update(Segment segment)
 {
     using (IDbConnection db = _factory.OpenDbConnection())
     {
         db.Update<Segment>(segment);
         return segment;
     }
 }
예제 #4
0
 private Segment PopulateDerived(Segment segment, IDbConnection db)
 {
     segment.NextId = NextSegmentId(segment, db);
     segment.FirstQuestionId = FirstQuestionId(segment, db);
     return segment;
 }
예제 #5
0
        private long NextSegmentId(Segment segment, IDbConnection db)
        {
            if (null == segment)
                return 0;

            return db.QueryScalar<long>(@"SELECT TOP 1 Id FROM Segment WHERE [Order] > @order AND SurveyId = @surveyId", new { order = segment.Order, surveyId = segment.SurveyId });
        }
예제 #6
0
 private long FirstQuestionId(Segment segment, IDbConnection db)
 {
     return db.QueryScalar<long>(@"SELECT TOP 1 Id FROM Question WHERE SegmentId = @segmentId ORDER BY [Order],Id", new { segmentId = segment.Id });
 }