async Task Save() { testSpec.SpinnerSaving = true; testSpec.SaveLabel = "Wait"; testSpec.ControlsDisabled = true; testSpec.TenorWeightDisabled = true; screenA.PlayDisabled = true; screenB.PlayDisabled = true; StateHasChanged(); // Push the created test to the API in JSON format // Start by creating a BlowSetCore object, which just has the parent data BlowSet, for each of A and B // Note implicit cast from child to parent BlowSetCore blowSetCoreA = blowSetA; BlowSetCore blowSetCoreB = blowSetB; // BlowSetCore has a BlowsCore list which is empty so far // Call the LoadBlowsCore method to populate it for each of A and B blowSetCoreA.LoadBlowsCore(blowSetA); blowSetCoreB.LoadBlowsCore(blowSetB); // Next use the Serializer method of the JsonSerializer class (in the System.Text.Json namespace) to create // a Json object from the BlowSetData object for each of A and B ABTestData aBTestData = new ABTestData { ABTestSpecA = JsonSerializer.Serialize(blowSetCoreA), ABTestSpecB = JsonSerializer.Serialize(blowSetCoreB) }; // Push the Json object to the API await TJBarnesService.GetHttpClient().PostAsJsonAsync("api/abtests", aBTestData); // Refresh the contents of the Select Test dropdown aBTestsData = (await TJBarnesService.GetHttpClient() .GetFromJsonAsync <ABTestData[]>("api/abtests")).ToList(); testSpec.SpinnerSaving = false; testSpec.Saved = true; StateHasChanged(); await Task.Delay(1000); testSpec.Saved = false; testSpec.SaveLabel = "Save"; testSpec.ControlsDisabled = false; testSpec.TenorWeightDisabled = TenorWeightSelect.TenorWeightDisabled(testSpec.Stage); screenA.PlayDisabled = false; screenB.PlayDisabled = false; StateHasChanged(); }
async Task Save() { testSpec.SpinnerSaving = true; testSpec.SaveLabel = "Wait"; testSpec.ControlsDisabled = true; testSpec.TenorWeightDisabled = true; screen.PlayDisabled = true; blowSet.Blows.Last().BellColor = Constants.DisabledUnstruckTestBellColor; StateHasChanged(); // Push the created test to the API in JSON format // Start by creating a BlowSetCore object, which just has the parent data BlowSet // Note implicit cast from child to parent BlowSetCore blowSetCore = blowSet; // BlowSetCore has a BlowsCore list which is empty so far // Call the LoadBlowsCore method to populate it blowSetCore.LoadBlowsCore(blowSet); // Next use the Serializer method of the JsonSerializer class (in the System.Text.Json namespace) to create // a Json object from the BlowSetData object var gapTestData = new GapTestData { GapTestSpec = JsonSerializer.Serialize(blowSetCore) }; // Push the Json object to the API await TJBarnesService.GetHttpClient().PostAsJsonAsync("api/gaptests", gapTestData); // Refresh the contents of the Select Test dropdown gapTestsData = (await TJBarnesService.GetHttpClient() .GetFromJsonAsync <GapTestData[]>("api/gaptests")).ToList(); testSpec.SpinnerSaving = false; testSpec.Saved = true; StateHasChanged(); await Task.Delay(1000); testSpec.Saved = false; testSpec.SaveLabel = "Save"; testSpec.ControlsDisabled = false; testSpec.TenorWeightDisabled = TenorWeightSelect.TenorWeightDisabled(testSpec.Stage); screen.PlayDisabled = false; blowSet.Blows.Last().BellColor = Constants.UnstruckTestBellColor; StateHasChanged(); }