Exemple #1
0
 private site_worker_versions MapSiteWorkerVersions(site_workers site_workers)
 {
     return(new site_worker_versions
     {
         WorkflowState = site_workers.WorkflowState,
         Version = site_workers.Version,
         CreatedAt = site_workers.CreatedAt,
         UpdatedAt = site_workers.UpdatedAt,
         MicrotingUid = site_workers.MicrotingUid,
         SiteId = site_workers.SiteId,
         WorkerId = site_workers.WorkerId,
         SiteWorkerId = site_workers.Id
     });
 }
Exemple #2
0
        public async Task Delete(MicrotingDbContext dbContext)
        {
            site_workers siteWorkers = await dbContext.site_workers.FirstOrDefaultAsync(x => x.Id == Id);

            if (siteWorkers == null)
            {
                throw new NullReferenceException($"Could not find site worker tish Id: {Id}");
            }

            siteWorkers.WorkflowState = Constants.Constants.WorkflowStates.Removed;

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

                dbContext.site_worker_versions.Add(MapSiteWorkerVersions(siteWorkers));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }