예제 #1
0
        public async Task <bool> RevokeCredentialsAsync(int patientId)
        {
            var credentials = await _context.Credentials
                              .Where(ec => ec.Connection.PatientId == patientId)
                              .Where(ec => ec.CredentialExchangeId != null)
                              .Where(ec => ec.RevokedCredentialDate == null)
                              .ToListAsync();

            foreach (var credential in credentials)
            {
                var success = credential.AcceptedCredentialDate == null
                    ? await _verifiableCredentialClient.DeleteCredentialAsync(credential)
                    : await _verifiableCredentialClient.RevokeCredentialAsync(credential);

                if (success)
                {
                    credential.RevokedCredentialDate = DateTimeOffset.Now;
                    await _verifiableCredentialClient.SendMessageAsync(credential.Connection.ConnectionId, "This credential has been revoked.");
                }
            }

            await _context.SaveChangesAsync();

            return(true);
        }
        public async Task <bool> RevokeCredentialsAsync(int enrolleeId)
        {
            var enrolleeCredentials = await _context.EnrolleeCredentials
                                      .Include(ec => ec.Credential)
                                      .Where(ec => ec.EnrolleeId == enrolleeId)
                                      .Where(ec => ec.Credential.CredentialExchangeId != null)
                                      .Where(ec => ec.Credential.RevokedCredentialDate == null)
                                      .Select(ec => ec.Credential)
                                      .ToListAsync();

            foreach (var credential in enrolleeCredentials)
            {
                if (await _verifiableCredentialClient.RevokeCredentialAsync(credential))
                {
                    credential.RevokedCredentialDate = DateTimeOffset.Now;
                }
            }

            await _context.SaveChangesAsync();

            return(true);
        }