示例#1
0
        public async Task Update(MicrotingDbContext dbContext)
        {
            survey_configurations surveyConfigurations =
                await dbContext.survey_configurations.FirstOrDefaultAsync(x => x.Id == Id);

            if (surveyConfigurations == null)
            {
                throw new NullReferenceException($"Could not find survey configuration with Id: {Id}");
            }

            surveyConfigurations.Name       = Name;
            surveyConfigurations.Stop       = Stop;
            surveyConfigurations.Start      = Start;
            surveyConfigurations.TimeOut    = TimeOut;
            surveyConfigurations.TimeToLive = TimeToLive;

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

                dbContext.survey_configuration_versions.Add(MapVersions(surveyConfigurations));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }
示例#2
0
        private survey_configuration_versions MapVersions(survey_configurations surveyConfiguration)
        {
            survey_configuration_versions surveyConfigurationVersions = new survey_configuration_versions
            {
                SurveyConfigurationId = surveyConfiguration.Id,
                Name          = surveyConfiguration.Name,
                Stop          = surveyConfiguration.Stop,
                Start         = surveyConfiguration.Start,
                TimeOut       = surveyConfiguration.TimeOut,
                TimeToLive    = surveyConfiguration.TimeToLive,
                Version       = surveyConfiguration.Version,
                CreatedAt     = surveyConfiguration.CreatedAt,
                UpdatedAt     = surveyConfiguration.UpdatedAt,
                WorkflowState = surveyConfiguration.WorkflowState,
                QuestionSetId = surveyConfiguration.QuestionSetId,
                MicrotingUid  = surveyConfiguration.MicrotingUid
            };

            return(surveyConfigurationVersions);
        }
示例#3
0
        public async Task Delete(MicrotingDbContext dbContext)
        {
            survey_configurations surveyConfigurations =
                await dbContext.survey_configurations.FirstOrDefaultAsync(x => x.Id == Id);

            if (surveyConfigurations == null)
            {
                throw new NullReferenceException($"Could not find survey configuration with Id: {Id}");
            }

            surveyConfigurations.WorkflowState = Constants.Constants.WorkflowStates.Removed;

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

                dbContext.survey_configuration_versions.Add(MapVersions(surveyConfigurations));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }