Ejemplo n.º 1
0
        /// <summary>
        /// Update the stored workflow config
        /// </summary>
        /// <param name="model">Dictionary representing the indexed permissions for the node</param>
        /// <returns>Bool representing success state</returns>
        public bool UpdateNodeConfig(Dictionary <int, List <UserGroupPermissionsPoco> > model)
        {
            if (null == model || !model.Any())
            {
                return(false);
            }

            KeyValuePair <int, List <UserGroupPermissionsPoco> > permission = model.First();

            _repo.DeleteNodeConfig(permission.Key);

            if (!permission.Value.Any())
            {
                return(false);
            }

            foreach (UserGroupPermissionsPoco poco in permission.Value)
            {
                _repo.AddPermission(poco);
            }

            Updated?.Invoke(this, new ConfigEventArgs(model, "Node"));

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Update the stored workflow config
        /// </summary>
        /// <param name="model">Dictionary representing the indexed permissions for the node</param>
        /// <returns>Bool representing success state</returns>
        public Task <bool> UpdateNodeConfigAsync(Dictionary <int, List <UserGroupPermissionsPoco> > model)
        {
            if (null == model || !model.Any())
            {
                return(Task.FromResult(false));
            }

            KeyValuePair <int, List <UserGroupPermissionsPoco> > permission = model.First();

            repo.DeleteNodeConfig(permission.Key);

            if (!permission.Value.Any())
            {
                return(Task.FromResult(false));
            }

            foreach (UserGroupPermissionsPoco poco in permission.Value)
            {
                repo.AddPermissionForNode(poco);
            }

            // emit event
            OnConfigUpdated(new OnConfigUpdatedEventArgs
            {
                Model     = model,
                UpdatedBy = Utility.GetCurrentUser()
            });

            return(Task.FromResult(true));
        }