Exemplo n.º 1
0
        public void Update(IPluginDbContext dbContext)
        {
            PluginGroupPermission pluginGroupPermission = dbContext.PluginGroupPermissions.FirstOrDefault(x => x.Id == Id);

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

            pluginGroupPermission.WorkflowState   = WorkflowState;
            pluginGroupPermission.GroupId         = pluginGroupPermission.GroupId;
            pluginGroupPermission.PermissionId    = pluginGroupPermission.PermissionId;
            pluginGroupPermission.IsEnabled       = pluginGroupPermission.IsEnabled;
            pluginGroupPermission.CreatedByUserId = CreatedByUserId;
            pluginGroupPermission.UpdatedByUserId = UpdatedByUserId;

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

                dbContext.PluginGroupPermissionVersions.Add(MapVersions(this));
                dbContext.SaveChanges();
            }
        }
Exemplo n.º 2
0
        private PluginGroupPermissionVersion MapVersions(PluginGroupPermission pluginGroupPermission)
        {
            PluginGroupPermissionVersion pluginGroupPermissionVersion = new PluginGroupPermissionVersion
            {
                Version                 = pluginGroupPermission.Version,
                GroupId                 = pluginGroupPermission.GroupId,
                PermissionId            = pluginGroupPermission.PermissionId,
                IsEnabled               = pluginGroupPermission.IsEnabled,
                CreatedAt               = pluginGroupPermission.CreatedAt,
                UpdatedAt               = pluginGroupPermission.UpdatedAt,
                CreatedByUserId         = pluginGroupPermission.CreatedByUserId,
                UpdatedByUserId         = pluginGroupPermission.UpdatedByUserId,
                WorkflowState           = pluginGroupPermission.WorkflowState,
                PluginGroupPermissionId = pluginGroupPermission.Id
            };

            return(pluginGroupPermissionVersion);
        }
Exemplo n.º 3
0
        public void Delete(IPluginDbContext dbContext)
        {
            PluginGroupPermission pluginGroupPermission = dbContext.PluginGroupPermissions.FirstOrDefault(x => x.Id == Id);

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

            pluginGroupPermission.WorkflowState = Constants.WorkflowStates.Removed;

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

                dbContext.PluginGroupPermissionVersions.Add(MapVersions(this));
                dbContext.SaveChanges();
            }
        }