示例#1
0
 private folder_versions MapFolderVersions(MicrotingDbContext _dbContext, folders folder)
 {
     return(new folder_versions
     {
         Name = folder.Name,
         Description = folder.Description,
         ParentId = folder.ParentId,
         FolderId = folder.Id,
         CreatedAt = folder.CreatedAt,
         UpdatedAt = folder.UpdatedAt,
         WorkflowState = folder.WorkflowState,
         MicrotingUid = folder.MicrotingUid,
         Version = folder.Version
     });
 }
示例#2
0
        public async Task Delete(MicrotingDbContext dbContext)
        {
            folders folder = dbContext.folders.SingleOrDefaultAsync(x => x.Id == Id).Result;

            if (folder == null)
            {
                throw new NullReferenceException($"Could not find area with Id: {Id}");
            }

            folder.WorkflowState = Constants.Constants.WorkflowStates.Removed;

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

                dbContext.folder_versions.Add(MapFolderVersions(dbContext, folder));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }
示例#3
0
        public async Task Update(MicrotingDbContext dbContext)
        {
            folders folder = dbContext.folders.FirstOrDefaultAsync(x => x.Id == Id).Result;

            if (folder == null)
            {
                throw new NullReferenceException($"Could not find area with Id: {Id}");
            }

            folder.Name        = Name;
            folder.Description = Description;
            folder.ParentId    = ParentId;

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

                dbContext.folder_versions.Add(MapFolderVersions(dbContext, folder));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }