Exemplo n.º 1
0
        public async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "put", "delete", Route = "manage/diagnosis-uids")] HttpRequest req)
        {
            var requestBody = await new StreamReader(req.Body).ReadToEndAsync();

            if (req.Method.Equals("put", StringComparison.OrdinalIgnoreCase))
            {
                var diagnosisUids = JsonConvert.DeserializeObject <IEnumerable <string> >(requestBody);

                await storage.AddDiagnosisUidsAsync(diagnosisUids);
            }
            else if (req.Method.Equals("delete", StringComparison.OrdinalIgnoreCase))
            {
                var diagnosisUids = JsonConvert.DeserializeObject <IEnumerable <string> >(requestBody);

                await storage.RemoveDiagnosisUidsAsync(diagnosisUids);
            }

            return(new OkResult());
        }
        public async Task Run([HttpTrigger(AuthorizationLevel.Function, "get", Route = "dev/dummy-keys")] HttpRequest req, ILogger logger)
        {
            logger.LogInformation("Adding dummy keys...");

            var diagnosisUid = random.Next(100001, 128000).ToString();

            await storage.AddDiagnosisUidsAsync(new[] { diagnosisUid });

            var submission = new SelfDiagnosisSubmission(true)
            {
                VerificationPayload = diagnosisUid,
                Regions             = PickRandom(new[] { "ca" }, new[] { "za" }, new[] { "ca", "za" }),
                AppPackageName      = "com.xamarin.exposurenotification.sampleapp",
                Platform            = PickRandom("android", "ios"),
                Keys = GetKeys()
            };

            await storage.SubmitPositiveDiagnosisAsync(submission);
        }