public async Task <IActionResult> CreateVouchers( [FromRoute] int count ) { if (!Hosting.IsDevelopment()) { return(Unauthorized()); } if (count <= 0 || count > 100) { throw new ArgumentOutOfRangeException(nameof(count), "Voucher count out of range"); } Logger.LogInformation("Creating {0} test vouchers", count); var testSource = await Mongo.GetSourceById(_testSourceId); var rnd = new Random(); var aim = (await Mongo.GetAims()).OrderBy(a => rnd.NextDouble()).First(); Logger.LogTrace("Test source: {0}, random aim '{1}'", testSource.Name, aim.Code); var now = DateTime.UtcNow; var voucherInfos = new VoucherCreatePayload.VoucherInfo[] { new VoucherCreatePayload.VoucherInfo { Aim = aim.Code, Latitude = rnd.NextBetween(5, 40), Longitude = rnd.NextBetween(5, 50), Timestamp = DateTime.UtcNow, Count = count } }; (var otcGen, var pwd) = await Operator.CreateGenerationRequest(testSource, new VoucherCreatePayload.Content { Nonce = Guid.NewGuid().ToString("N"), SourceId = testSource.Id.ToString(), Vouchers = voucherInfos }, isPreVerified : true); Logger.LogDebug("New voucher generation request created with code {0}", otcGen); return(Ok(new { OtcGen = UrlGenerator.GenerateRedeemUrl(otcGen), Pin = pwd })); }