public async Task <IActionResult> GetAttributesScheme(long accountId) { AccountDescriptor account = _accountsService.GetById(accountId); if (account == null) { throw new AccountNotFoundException(accountId); } if (account.AccountType != AccountType.IdentityProvider) { throw new UnexpectedAccountTypeException(accountId, account.AccountType); } string issuer = account.PublicSpendKey.ToHexString(); IEnumerable <AttributeDefinition> attributeDefinitions = _dataAccessService.GetAttributesSchemeByIssuer(issuer, true) .Select(a => new AttributeDefinition { SchemeId = a.IdentitiesSchemeId, AttributeName = a.AttributeName, SchemeName = a.AttributeSchemeName, Alias = a.Alias, Description = a.Description, IsActive = a.IsActive, IsRoot = a.CanBeRoot }); IdentityAttributeSchemaDto rootAttributeScheme = null; var rootAttrDefinition = attributeDefinitions.FirstOrDefault(a => a.IsRoot); if (rootAttrDefinition != null) { rootAttributeScheme = new IdentityAttributeSchemaDto { AttributeName = rootAttrDefinition.AttributeName, Alias = rootAttrDefinition.Alias }; } IdentityAttributesSchemaDto schemaDto = new IdentityAttributesSchemaDto { RootAttribute = rootAttributeScheme, AssociatedAttributes = attributeDefinitions .Where(a => !a.IsRoot && a.SchemeName != AttributesSchemes.ATTR_SCHEME_NAME_PASSWORD) .Select(a => new IdentityAttributeSchemaDto { AttributeName = a.AttributeName, Alias = a.Alias }).ToList() }; return(Ok(schemaDto)); }
public IActionResult GetAttributesSchema() { Tuple <AttributeType, string> root = _identityAttributesService.GetRootAttributeType(); IEnumerable <Tuple <AttributeType, string> > associated = _identityAttributesService.GetAssociatedAttributeTypes(); IdentityAttributesSchemaDto schemaDto = new IdentityAttributesSchemaDto { RootAttribute = new IdentityAttributeSchemaDto { AttributeType = (uint)root.Item1, Name = root.Item2 }, AssociatedAttributes = associated.Select(a => new IdentityAttributeSchemaDto { AttributeType = (uint)a.Item1, Name = a.Item2 }).ToList() }; return(Ok(schemaDto)); }