Esempio n. 1
0
        /// <summary>
        /// Method to update an <see cref="AclActionEntity"/>.
        /// </summary>
        /// <param name="entity">An Entity to update.</param>
        /// <returns>The updated Entity.</returns>
        public async Task <AclActionEntity> UpdateAsync(AclActionEntity entity)
        {
            // Remove AclGroups in AclActions dependencies.
            DeleteDependencyAclGroups(entity);

            // Update item informations.
            entity = Connector.Update(entity).Entity;

            await SaveAsync();

            // Return the updated item.
            return(entity);
        }
Esempio n. 2
0
        public AclActionEntity RemoveAclGroupDependency(int aclActionId, int aclGroupId, bool save = true)
        {
            AclActionOptionsSelect options = new AclActionOptionsSelect {
                PrimaryKey = aclActionId
            };

            options.Dependencies.Add(EnumEntitiesDependencies.AclGroupsInAclActions);

            AclActionEntity item = Select(options);

            item.AclGroupsInAclActions.Remove(item.AclGroupsInAclActions.SingleOrDefault(x => x.AclGroupId == aclGroupId));

            return(Update(item, save));
        }
Esempio n. 3
0
        /// <summary>
        /// Method to delete <see cref="AclGroupsInAclActions"/> associations.
        /// </summary>
        /// <param name="entity">The <see cref="AclActionEntity"/> to process with.</param>
        private async void DeleteDependencyAclGroups(AclActionEntity entity)
        {
            if (entity.AclGroupsInAclActions.DepPKeysRemoved.Count > 0)
            {
                await DeleteDependencyAsync(
                    new EntityManagerDeleteDependency { Name = "AclGroupsInAclActions", key = "AclActionId", keyList = "AclGroupId" },
                    entity.PrimaryKey,
                    entity.AclGroupsInAclActions.DepPKeysRemoved
                    );

                entity.AclGroupsInAclActions.DepPKeysRemoved.Clear();

                log.Debug("Delete AclGroups in AclActions associations. Done.");
            }
        }
Esempio n. 4
0
        public AclActionEntity AddAclGroupDependency(int aclActionId, int aclGroupId, bool save = true)
        {
            AclActionOptionsSelect options = new AclActionOptionsSelect {
                PrimaryKey = aclActionId
            };

            options.Dependencies.Add(EnumEntitiesDependencies.AclGroupsInAclActions);

            AclActionEntity item = Select(options);

            item.AclGroupsInAclActions.Add(new AclGroupsInAclActions {
                AclGroupId = aclGroupId
            });

            return(Update(item, save));
        }