コード例 #1
0
        public RoleTargetRecord AddRoleRuleCollection(string roleName, RoleCollectionRecord collection)
        {
            var model = new RoleTargetRecord()
                            {
                                RoleCollectionRecord = collection,
                                RoleName = roleName,
                            };

            collection.RoleTargetRecords.Add(model);

            this.roleTargetRecordRepository.Create(model);

            return model;
        }
コード例 #2
0
        public RoleCollectionRecord CreateDefaultCollection(bool defaultRoles, IList<string> roles)
        {
            var collection = new RoleCollectionRecord();
            collection.Name = "Default";

            this.roleCollectionRecordRepository.Create(collection);

            if (defaultRoles)
            {
                foreach (var item in this.roleService.GetRoles())
                {
                    var roleGroup = this.AddRoleRuleCollection(item.Name, collection);
                }
            }

            if (roles == null || roles.Count == 0)
                return collection;

            foreach (var role in roles)
            {
                if (collection.RoleTargetRecords.Any(e => e.RoleName.Equals(role, StringComparison.CurrentCultureIgnoreCase)))
                    continue;

                this.AddRoleRuleCollection(role, collection);
            }

            return collection;
        }
コード例 #3
0
        private void UpdateDefaultCollection(RoleCollectionRecord collection)
        {
            foreach (var item in this.roleService.GetRoles())
            {
                if (collection.RoleTargetRecords.Any(e => e.RoleName.Equals(item.Name)))
                    continue;

                this.AddRoleRuleCollection(item.Name, collection);
                //var roleGroup = this.AddRoleRuleCollection(item.Name, collection);
            }
        }