public async Task <DiagnosisKey> AddDiagnosisKey(DiagnosisKey newDiagnosisKey) { await _context.DiagnosisKeys.AddAsync(newDiagnosisKey); await _context.SaveChangesAsync(); return(newDiagnosisKey); }
private DiagnosisKey Map(InteropKeyFormatterArgs arg) { var result = new DiagnosisKey { KeyData = ByteString.CopyFrom(arg.Value.KeyData), DaysSinceOnsetOfSymptoms = arg.DaysSinceSymtpomsOnset, //TODO move to RSN (int) (Math.Floor((_DateTimeProvider.Snapshot - arg.DateOfSyptomsOnset).TotalDays)), RollingPeriod = (uint)arg.Value.RollingPeriod, RollingStartIntervalNumber = (uint)arg.Value.RollingStartNumber, TransmissionRiskLevel = arg.TransmissionRiskLevel, Origin = arg.Origin, ReportType = arg.ReportType, }; result.VisitedCountries.AddRange(arg.CountriesOfInterest); //arg.CountriesOfInterest.Except("NL")? return(result); }
private bool Valid(DiagnosisKey value) { if (value == null) { return(false); } if (!_countryValidator.IsValid(value.Origin)) { return(false); } var rollingStartMin = _tekValidatorConfig.RollingStartNumberMin; var rollingStartToday = _dateTimeProvider.Snapshot.Date.ToRollingStartNumber(); if (!(rollingStartMin <= value.RollingStartIntervalNumber && value.RollingStartIntervalNumber <= rollingStartToday)) { return(false); } if (!(UniversalConstants.RollingPeriodRange.Lo <= value.RollingPeriod && value.RollingPeriod <= UniversalConstants.RollingPeriodRange.Hi)) { return(false); } if (value.KeyData == null) { return(false); } if (value.KeyData.Length != UniversalConstants.DailyKeyDataByteCount) { return(false); } return(true); }