Exemplo n.º 1
0
 private question_set_versions MapVersions(question_sets questionSet)
 {
     return(new question_set_versions
     {
         QuestionSetId = questionSet.Id,
         Name = questionSet.Name,
         Share = questionSet.Share,
         HasChild = questionSet.HasChild,
         PossiblyDeployed = questionSet.PosiblyDeployed,
         Version = questionSet.Version,
         CreatedAt = questionSet.CreatedAt,
         UpdatedAt = questionSet.UpdatedAt,
         WorkflowState = questionSet.WorkflowState,
         MicrotingUid = questionSet.MicrotingUid
     });
 }
Exemplo n.º 2
0
        public async Task Delete(MicrotingDbContext dbContext)
        {
            question_sets questionSet = await dbContext.question_sets.FirstOrDefaultAsync(x => x.Id == Id);

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

            questionSet.WorkflowState = Constants.Constants.WorkflowStates.Removed;

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

                dbContext.question_set_versions.Add(MapVersions(questionSet));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }
Exemplo n.º 3
0
        public async Task Update(MicrotingDbContext dbContext)
        {
            question_sets questionSet = await dbContext.question_sets.FirstOrDefaultAsync(x => x.Id == Id);

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

            questionSet.Name            = Name;
            questionSet.Share           = Share;
            questionSet.HasChild        = HasChild;
            questionSet.PosiblyDeployed = PosiblyDeployed;

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

                dbContext.question_set_versions.Add(MapVersions(questionSet));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }