private void SetCurrentAndParentRoleTypes( IAuthorization authorization, Structure structure, Container rootContainer, string rootName, string service, IEnumerable<Role> roles ) { Container current = rootContainer; do { foreach (var role in roles) if (ContainsRoleType(structure, current, role.RoleType)) { var permissions = role.Rule.Permissions.Where( (sp) => sp.ServiceName == service ).Select( (sp) => sp.Name ); authorization.AddGroupPermission( rootName, authorization.GetGroupName(structure.Id, current.Id, role.RoleTypeName), permissions ); } current = current.ParentContainer; } while (current != null); }
private void SetChildsRoleTypes( IAuthorization authorization, Structure structure, Container rootContainer, string rootName, string service, IEnumerable<Role> roles ) { if (rootContainer.Childs == null) return; foreach (var child in rootContainer.Childs) { SetChildsRoleTypes(authorization, structure, child, service, rootName, roles); foreach (var role in roles) if (ContainsRoleType(structure, child, role.RoleType)) { var permissions = role.Rule.Permissions.Where( (sp) => sp.ServiceName == service ).Select( (sp) => sp.Name ); authorization.AddGroupPermission( rootName, authorization.GetGroupName(structure.Id, child.Id, role.RoleTypeName), permissions ); } } }