Ejemplo n.º 1
0
        // Create an invitation to establish a connection between the agents.
        public async Task <JObject> CreateConnectionAsync(Enrollee enrollee)
        {
            var alias      = enrollee.Id.ToString();
            var invitation = await _verifiableCredentialClient.CreateInvitationAsync(alias);

            var invitationUrl          = invitation.Value <string>("invitation_url");
            var credentialDefinitionId = await _verifiableCredentialClient.GetCredentialDefinitionIdAsync(SCHEMA_ID);

            QRCodeGenerator qrGenerator         = new QRCodeGenerator();
            QRCodeData      qrCodeData          = qrGenerator.CreateQrCode(invitationUrl, QRCodeGenerator.ECCLevel.Q);
            Base64QRCode    qrCode              = new Base64QRCode(qrCodeData);
            string          qrCodeImageAsBase64 = qrCode.GetGraphic(20, "#003366", "#ffffff");

            enrollee.Credential = new Credential
            {
                SchemaId = SCHEMA_ID,
                CredentialDefinitionId = credentialDefinitionId,
                Alias        = alias,
                Base64QRCode = qrCodeImageAsBase64
            };

            var created = await _context.SaveChangesAsync();

            if (created < 1)
            {
                throw new InvalidOperationException("Could not store connection invitation.");
            }

            // TODO after testing don't need to pass back the invitation
            return(invitation);
        }
Ejemplo n.º 2
0
        private async Task <int> CreateInvitation(Connection connection)
        {
            var invitation = await _verifiableCredentialClient.CreateInvitationAsync(connection.PatientId.ToString());

            var invitationUrl = invitation.Value <string>("invitation_url");

            QRCodeGenerator qrGenerator         = new QRCodeGenerator();
            QRCodeData      qrCodeData          = qrGenerator.CreateQrCode(invitationUrl, QRCodeGenerator.ECCLevel.Q);
            Base64QRCode    qrCode              = new Base64QRCode(qrCodeData);
            string          qrCodeImageAsBase64 = qrCode.GetGraphic(20, "#003366", "#ffffff");

            connection.Base64QRCode = qrCodeImageAsBase64;
            return(await _context.SaveChangesAsync());
        }