Beispiel #1
0
 private question_versions MapVersions(questions question)
 {
     return(new question_versions
     {
         QuestionSetId = question.QuestionSetId,
         Type = question.Type,
         Image = question.Image,
         Maximum = question.Maximum,
         Minimum = question.Minimum,
         Prioritised = question.Prioritised,
         RefId = question.RefId,
         FontSize = question.FontSize,
         QuestionId = question.Id,
         MaxDuration = question.MaxDuration,
         MinDuration = question.MinDuration,
         ImagePosition = question.ImagePosition,
         QuestionType = question.QuestionType,
         ValidDisplay = question.ValidDisplay,
         QuestionIndex = question.QuestionIndex,
         BackButtonEnabled = question.BackButtonEnabled,
         ContinuousQuestionId = question.ContinuousQuestionId,
         CreatedAt = question.CreatedAt,
         Version = question.Version,
         UpdatedAt = question.UpdatedAt,
         WorkflowState = question.WorkflowState,
         MicrotingUid = question.MicrotingUid
     });
 }
Beispiel #2
0
        public async Task Update(MicrotingDbContext dbContext)
        {
            questions question = await dbContext.questions.FirstOrDefaultAsync(x => x.Id == Id);

            if (question == null)
            {
                throw new NullReferenceException($"Could no find question with Id: {Id}");
            }

            question.Type                 = Type;
            question.Image                = Image;
            question.BackButtonEnabled    = BackButtonEnabled;
            question.Maximum              = Maximum;
            question.Minimum              = Minimum;
            question.Prioritised          = Prioritised;
            question.RefId                = RefId;
            question.FontSize             = FontSize;
            question.MaxDuration          = MaxDuration;
            question.MinDuration          = MinDuration;
            question.ImagePosition        = ImagePosition;
            question.QuestionType         = QuestionType;
            question.ValidDisplay         = ValidDisplay;
            question.QuestionIndex        = QuestionIndex;
            question.QuestionSetId        = QuestionSetId;
            question.ContinuousQuestionId = ContinuousQuestionId;

            if (dbContext.ChangeTracker.HasChanges())
            {
                Version  += 1;
                UpdatedAt = DateTime.UtcNow;

                dbContext.question_versions.Add(MapVersions(question));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }
Beispiel #3
0
        public async Task Delete(MicrotingDbContext dbContext)
        {
            questions question = await dbContext.questions.FirstOrDefaultAsync(x => x.Id == Id);

            if (question == null)
            {
                throw new NullReferenceException($"Could no find question with Id: {Id}");
            }

            question.WorkflowState = Constants.Constants.WorkflowStates.Removed;

            if (dbContext.ChangeTracker.HasChanges())
            {
                Version  += 1;
                UpdatedAt = DateTime.UtcNow;

                dbContext.question_versions.Add(MapVersions(question));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }