Beispiel #1
0
 private site_tag_versions MapVersions(site_tags siteTags)
 {
     return(new site_tag_versions
     {
         SiteId = siteTags.SiteId,
         TagId = siteTags.TagId,
         WorkflowState = siteTags.WorkflowState,
         Version = siteTags.Version,
         CreatedAt = siteTags.CreatedAt,
         UpdatedAt = siteTags.UpdatedAt,
         SiteTagId = siteTags.Id
     });
 }
Beispiel #2
0
        public async Task Delete(MicrotingDbContext dbContext)
        {
            site_tags siteTags = await dbContext.SiteTags.FirstOrDefaultAsync(x => x.Id == Id).ConfigureAwait(false);

            if (siteTags == null)
            {
                throw new NullReferenceException($"Could not find SiteTag withe Id {Id}");
            }

            siteTags.WorkflowState = Constants.Constants.WorkflowStates.Removed;

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

                dbContext.SiteTagVersions.Add(MapVersions(siteTags));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }