Exemplo n.º 1
0
 private check_list_site_versions MapCheckListSiteVersions(check_list_sites checkListSite)
 {
     return(new check_list_site_versions
     {
         CheckListId = checkListSite.CheckListId,
         CreatedAt = checkListSite.CreatedAt,
         UpdatedAt = checkListSite.UpdatedAt,
         LastCheckId = checkListSite.LastCheckId,
         MicrotingUid = checkListSite.MicrotingUid,
         SiteId = checkListSite.SiteId,
         Version = checkListSite.Version,
         WorkflowState = checkListSite.WorkflowState,
         CheckListSiteId = checkListSite.Id,
         FolderId = checkListSite.FolderId
     });
 }
Exemplo n.º 2
0
        public async Task Delete(MicrotingDbContext dbContext)
        {
            check_list_sites checkListSites = await dbContext.check_list_sites.FirstOrDefaultAsync(x => x.Id == Id);

            if (checkListSites == null)
            {
                throw  new NullReferenceException($"Could not find Check List Site with Id: {Id}");
            }

            checkListSites.WorkflowState = Constants.Constants.WorkflowStates.Removed;

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

                dbContext.check_list_site_versions.Add(MapCheckListSiteVersions(checkListSites));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }
Exemplo n.º 3
0
        public async Task Update(MicrotingDbContext dbContext)
        {
            check_list_sites checkListSites = await dbContext.check_list_sites.FirstOrDefaultAsync(x => x.Id == Id);

            if (checkListSites == null)
            {
                throw  new NullReferenceException($"Could not find Check List Site with Id: {Id}");
            }

            checkListSites.SiteId       = SiteId;
            checkListSites.CheckListId  = CheckListId;
            checkListSites.MicrotingUid = MicrotingUid;
            checkListSites.LastCheckId  = LastCheckId;
            checkListSites.FolderId     = FolderId;

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

                dbContext.check_list_site_versions.Add(MapCheckListSiteVersions(checkListSites));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }