Example #1
0
        public override async Task InitializeAsync(object navigationData)
        {
            _connectionRecord = navigationData as ConnectionRecord;
            var context = await _agentContextProvider.GetContextAsync();

            var credentialsRecords = await _credentialService.ListAsync(context);

            List <SchemaRecord>     schemasList     = new List <SchemaRecord>();
            List <DefinitionRecord> definitionsList = new List <DefinitionRecord>();

            foreach (var credentialRecord in credentialsRecords)
            {
                if (credentialRecord.State == CredentialState.Rejected)
                {
                    continue;
                }
                var schemaResp = await _ledgerService.LookupSchemaAsync(context, credentialRecord.SchemaId);

                var schemaJobj = JObject.Parse(schemaResp?.ObjectJson ?? "");
                schemasList.Add(new SchemaRecord {
                    Id = schemaResp.Id, Name = schemaJobj.GetValue("name").ToString()
                });
                var defResp = await _ledgerService.LookupDefinitionAsync(context, credentialRecord.CredentialDefinitionId);

                definitionsList.Add(new DefinitionRecord {
                    Id = defResp.Id
                });
            }
            Schemas.InsertRange(schemasList);
            CredDefinitions.InsertRange(definitionsList);

            //CredDefinitions = await _schemaService.ListCredentialDefinitionsAsync(context.Wallet);
            await base.InitializeAsync(navigationData);
        }