Exemplo n.º 1
0
        public async Task Update(MicrotingDbContext dbContext)
        {
            check_lists checkList = await dbContext.check_lists.FirstOrDefaultAsync(x => x.Id == Id);

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

            checkList.Label               = Label;
            checkList.Description         = Description;
            checkList.Custom              = Custom;
            checkList.ParentId            = ParentId;
            checkList.Repeated            = Repeated;
            checkList.DisplayIndex        = DisplayIndex;
            checkList.CaseType            = CaseType;
            checkList.FolderName          = FolderName;
            checkList.ReviewEnabled       = ReviewEnabled;
            checkList.ManualSync          = ManualSync;
            checkList.ExtraFieldsEnabled  = ExtraFieldsEnabled;
            checkList.DoneButtonEnabled   = DoneButtonEnabled;
            checkList.ApprovalEnabled     = ApprovalEnabled;
            checkList.MultiApproval       = MultiApproval;
            checkList.FastNavigation      = FastNavigation;
            checkList.DownloadEntities    = DownloadEntities;
            checkList.Field1              = Field1;
            checkList.Field2              = Field2;
            checkList.Field3              = Field3;
            checkList.Field4              = Field4;
            checkList.Field5              = Field5;
            checkList.Field6              = Field6;
            checkList.Field7              = Field7;
            checkList.Field8              = Field8;
            checkList.Field9              = Field9;
            checkList.Field10             = Field10;
            checkList.Color               = Color;
            checkList.QuickSyncEnabled    = QuickSyncEnabled;
            checkList.OriginalId          = OriginalId;
            checkList.JasperExportEnabled = JasperExportEnabled;
            checkList.DocxExportEnabled   = DocxExportEnabled;

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

                dbContext.check_list_versions.Add(MapCheckListVersions(checkList));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }
Exemplo n.º 2
0
 private check_list_versions MapCheckListVersions(check_lists checkList)
 {
     return(new check_list_versions
     {
         CreatedAt = checkList.CreatedAt,
         UpdatedAt = checkList.UpdatedAt,
         Label = checkList.Label,
         Description = checkList.Description,
         Custom = checkList.Custom,
         WorkflowState = checkList.WorkflowState,
         ParentId = checkList.ParentId,
         Repeated = checkList.Repeated,
         Version = checkList.Version,
         CaseType = checkList.CaseType,
         FolderName = checkList.FolderName,
         DisplayIndex = checkList.DisplayIndex,
         ReviewEnabled = checkList.ReviewEnabled,
         ManualSync = checkList.ManualSync,
         ExtraFieldsEnabled = checkList.ExtraFieldsEnabled,
         DoneButtonEnabled = checkList.DoneButtonEnabled,
         ApprovalEnabled = checkList.ApprovalEnabled,
         MultiApproval = checkList.MultiApproval,
         FastNavigation = checkList.FastNavigation,
         DownloadEntities = checkList.DownloadEntities,
         Field1 = checkList.Field1,
         Field2 = checkList.Field2,
         Field3 = checkList.Field3,
         Field4 = checkList.Field4,
         Field5 = checkList.Field5,
         Field6 = checkList.Field6,
         Field7 = checkList.Field7,
         Field8 = checkList.Field8,
         Field9 = checkList.Field9,
         Field10 = checkList.Field10,
         Color = checkList.Color,
         QuickSyncEnabled = checkList.QuickSyncEnabled,
         OriginalId = checkList.OriginalId,
         JasperExportEnabled = checkList.JasperExportEnabled,
         DocxExportEnabled = checkList.DocxExportEnabled,
         CheckListId = checkList.Id
     });
 }
Exemplo n.º 3
0
        public async Task Delete(MicrotingDbContext dbContext)
        {
            check_lists checkList = await dbContext.check_lists.FirstOrDefaultAsync(x => x.Id == Id);

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

            checkList.WorkflowState = Constants.Constants.WorkflowStates.Removed;

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

                dbContext.check_list_versions.Add(MapCheckListVersions(checkList));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }