Пример #1
0
 public static DbTemporaryExposureKey FromKey(ExposureKey key, string region)
 => new DbTemporaryExposureKey
 {
     Base64KeyData                 = key.Key,
     TimestampMsSinceEpoch         = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
     RollingStartSecondsSinceEpoch = key.RollingStart,
     RollingDuration               = key.RollingDuration,
     TransmissionRiskLevel         = key.TransmissionRisk,
     Region = region
 };
        protected override async Task Handle(AddExposureKeysCommand request, CancellationToken cancellationToken)
        {
            foreach (var key in request.ExposureKeys)
            {
                var now         = DateTime.UtcNow;
                var createdOn   = now;
                var expiration  = now.Add(request.ExpirationTime);
                var exposureKey = new ExposureKey(key.TemporaryExposureKey, key.RollingStartNumber, key.RollingDuration, createdOn, expiration);
                await context.ExposureKeys.AddAsync(exposureKey, cancellationToken);
            }

            await context.SaveEntitiesAsync(cancellationToken);
        }