示例#1
0
        public async Task Create(OuterInnerResourcePnDbContext dbContext)
        {
            CreatedAt     = DateTime.Now;
            UpdatedAt     = DateTime.Now;
            Version       = 1;
            WorkflowState = eForm.Infrastructure.Constants.Constants.WorkflowStates.Created;

            dbContext.OuterInnerResources.Add(this);
            dbContext.SaveChanges();

            dbContext.OuterInnerResourceVersions.Add(MapVersions(this));
            dbContext.SaveChanges();
        }
示例#2
0
        public async Task Update(OuterInnerResourcePnDbContext dbContext)
        {
            ResourceTimeRegistration resourceTimeRegistration = dbContext.ResourceTimeRegistrations.FirstOrDefault(x => x.Id == Id);

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

            resourceTimeRegistration.InnerResourceId = InnerResourceId;
            resourceTimeRegistration.OuterResourceId = OuterResourceId;
            resourceTimeRegistration.DoneAt          = DoneAt;
            resourceTimeRegistration.SDKCaseId       = SDKCaseId;
            resourceTimeRegistration.SDKFieldValueId = SDKFieldValueId;
            resourceTimeRegistration.TimeInSeconds   = TimeInSeconds;
            resourceTimeRegistration.TimeInMinutes   = TimeInMinutes;
            resourceTimeRegistration.TimeInHours     = TimeInHours;
            resourceTimeRegistration.SDKSiteId       = SDKSiteId;

            if (dbContext.ChangeTracker.HasChanges())
            {
                resourceTimeRegistration.UpdatedAt = DateTime.Now;
                resourceTimeRegistration.Version  += 1;

                dbContext.ResourceTimeRegistrationVersions.Add(MapVersions(resourceTimeRegistration));
                dbContext.SaveChanges();
            }
        }
        public static void SeedData(OuterInnerResourcePnDbContext dbContext)
        {
            var seedData = new OuterInnerResourceConfigurationSeedData();
            var configurationList = seedData.Data;
            foreach (var configurationItem in configurationList)
            {
                if (!dbContext.PluginConfigurationValues.Any(x=>x.Name == configurationItem.Name))
                {
                    var newConfigValue = new PluginConfigurationValue()
                    {
                        Name = configurationItem.Name,
                        Value = configurationItem.Value,
                        CreatedAt = DateTime.UtcNow,
                        Version = 1,
                        WorkflowState = Constants.WorkflowStates.Created,
                        CreatedByUserId = 1
                    };
                    dbContext.PluginConfigurationValues.Add(newConfigValue);
                    dbContext.SaveChanges();
                }
            }

            // Seed plugin permissions
            var newPermissions = OuterInnerResourcePermissionsSeedData.Data
                .Where(p => dbContext.PluginPermissions.All(x => x.ClaimName != p.ClaimName))
                .Select(p => new PluginPermission
                {
                    PermissionName = p.PermissionName,
                    ClaimName = p.ClaimName,
                    CreatedAt = DateTime.UtcNow,
                    Version = 1,
                    WorkflowState = Constants.WorkflowStates.Created,
                    CreatedByUserId = 1
                }
                );
            dbContext.PluginPermissions.AddRange(newPermissions);

            dbContext.SaveChanges();
        }
示例#4
0
        public async Task Delete(OuterInnerResourcePnDbContext dbContext)
        {
            OuterInnerResource outerInnerResource = dbContext.OuterInnerResources.FirstOrDefault(x => x.Id == Id);

            if (outerInnerResource == null)
            {
                throw new NullReferenceException($"Could not find machineArea with id: {Id}");
            }

            outerInnerResource.WorkflowState = eForm.Infrastructure.Constants.Constants.WorkflowStates.Removed;

            if (dbContext.ChangeTracker.HasChanges())
            {
                outerInnerResource.UpdatedAt = DateTime.Now;
                outerInnerResource.Version  += 1;

                dbContext.OuterInnerResourceVersions.Add(MapVersions(outerInnerResource));
                dbContext.SaveChanges();
            }
        }
示例#5
0
        public async Task Delete(OuterInnerResourcePnDbContext dbContext)
        {
            ResourceTimeRegistration resourceTimeRegistration = dbContext.ResourceTimeRegistrations.FirstOrDefault(x => x.Id == Id);

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

            resourceTimeRegistration.WorkflowState = eForm.Infrastructure.Constants.Constants.WorkflowStates.Removed;

            if (dbContext.ChangeTracker.HasChanges())
            {
                resourceTimeRegistration.UpdatedAt = DateTime.Now;
                resourceTimeRegistration.Version  += 1;

                dbContext.ResourceTimeRegistrationVersions.Add(MapVersions(resourceTimeRegistration));
                dbContext.SaveChanges();
            }
        }
示例#6
0
        public async Task Update(OuterInnerResourcePnDbContext dbContext)
        {
            OuterInnerResource outerInnerResource = dbContext.OuterInnerResources.FirstOrDefault(x => x.Id == Id);

            if (outerInnerResource == null)
            {
                throw new NullReferenceException($"Could not find machineArea with id: {Id}");
            }

            outerInnerResource.OuterResourceId = OuterResourceId;
            outerInnerResource.InnerResourceId = InnerResourceId;

            if (dbContext.ChangeTracker.HasChanges())
            {
                outerInnerResource.UpdatedAt = DateTime.Now;
                outerInnerResource.Version  += 1;

                dbContext.OuterInnerResourceVersions.Add(MapVersions(outerInnerResource));
                dbContext.SaveChanges();
            }
        }
示例#7
0
        public async Task Update(OuterInnerResourcePnDbContext dbContext)
        {
            InnerResource innerResource = dbContext.InnerResources.FirstOrDefault(x => x.Id == Id);

            if (innerResource == null)
            {
                throw new NullReferenceException($"Could not find Machine with id: {Id}");
            }

            innerResource.Name       = Name;
            innerResource.ExternalId = ExternalId;

            if (dbContext.ChangeTracker.HasChanges())
            {
                innerResource.UpdatedAt = DateTime.Now;
                innerResource.Version  += 1;

                dbContext.InnerResourceVersions.Add(MapVersions(innerResource));
                dbContext.SaveChanges();
            }
        }