protected async Task ValidateMethod(int newMethodId) { // Start spinner Performance.NewMethods[newMethodId].Validating = true; // Clear any existing new method results Performance.NewMethods[newMethodId].Status = string.Empty; Performance.NewMethods[newMethodId].Title = string.Empty; // Check for nothing entered if (!string.IsNullOrEmpty(Performance.NewMethods[newMethodId].Name) || !string.IsNullOrEmpty(Performance.NewMethods[newMethodId].PlaceNotation) || Performance.NewMethods[newMethodId].Stage != 0) { // Get a test from the API NewMethod newMethod = await CompLibService.GetHttpClient() .GetFromJsonAsync <NewMethod>($"method/validate?stage={Performance.NewMethods[newMethodId].Stage}" + $"&name={Performance.NewMethods[newMethodId].Name}" + $"&placenotation={Performance.NewMethods[newMethodId].PlaceNotation}"); // Populate the NewMethod service if (newMethod.Method != null) { NewMethod.Method.Title = newMethod.Method.Title; NewMethod.Method.PlaceNotation = newMethod.Method.PlaceNotation; NewMethod.Properties.LeadheadCode = newMethod.Properties.LeadheadCode; NewMethod.Properties.LeadHead = newMethod.Properties.LeadHead; Performance.NewMethods[newMethodId].Title = newMethod.Method.Title; } else { Performance.NewMethods[newMethodId].Title = "Error"; } NewMethod.Messages.Clear(); if (newMethod.Messages.Count != 0) { foreach (var message in newMethod.Messages) { NewMethod.Messages.Add(message); } Performance.NewMethods[newMethodId].Status = "See messages"; } else { Performance.NewMethods[newMethodId].Status = "No messages"; } } Performance.NewMethods[newMethodId].Validating = false; if (!string.IsNullOrEmpty(Performance.NewMethods[newMethodId].Title)) { ActivatePopUp(PopUp.NewMethodResult); } }
protected async Task CompImport() { // Start spinner CompImporting = true; // Clear any existing composition info Performance.Length = string.Empty; Performance.Title = string.Empty; Performance.Composer = string.Empty; Performance.Detail = string.Empty; // Check that valid id has been entered if (!string.IsNullOrEmpty(Performance.CompLibId)) { var response = await CompLibService.GetHttpClient() .GetAsync($"composition/{Performance.CompLibId}"); if (response.StatusCode == System.Net.HttpStatusCode.OK) { CompImport compImport = await CompLibService.GetHttpClient() .GetFromJsonAsync <CompImport>($"composition/{Performance.CompLibId}"); int firstSpace = compImport.Title.IndexOf(" "); Performance.Length = compImport.Title.Substring(0, firstSpace); Performance.Title = compImport.Title.Substring(firstSpace + 1); if (compImport.ComposerDetails.Length != 0) { Performance.Composer = compImport.ComposerDetails.First().Name; } else { Performance.Composer = string.Empty; } Performance.Detail = compImport.MethodDetails; } else { Performance.Title = "*** Composition not found ***"; } } else { Performance.Title = "*** Composition not found ***"; } CompImporting = false; }