Ejemplo n.º 1
0
 private site_survey_configuration_versions MapVersions(site_survey_configurations siteSurveyConfiguration)
 {
     return(new site_survey_configuration_versions
     {
         SurveyConfigurationId = siteSurveyConfiguration.SurveyConfigurationId,
         SiteId = siteSurveyConfiguration.SiteId,
         SiteSurveyConfigurationId = siteSurveyConfiguration.Id,
         CreatedAt = siteSurveyConfiguration.CreatedAt,
         UpdatedAt = siteSurveyConfiguration.UpdatedAt,
         WorkflowState = siteSurveyConfiguration.WorkflowState,
         Version = siteSurveyConfiguration.Version,
         MicrotingUid = siteSurveyConfiguration.MicrotingUid
     });
 }
Ejemplo n.º 2
0
        public async Task Delete(MicrotingDbContext dbContext)
        {
            site_survey_configurations siteSurveyConfiguration =
                await dbContext.site_survey_configurations.FirstOrDefaultAsync(x => x.Id == Id);

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

            siteSurveyConfiguration.WorkflowState = Constants.Constants.WorkflowStates.Removed;

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

                dbContext.site_survey_configuration_versions.Add(MapVersions(siteSurveyConfiguration));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }