private async void NewEncounter(object sender, EventArgs e) { if (IsBusy) { return; } IsBusy = true; var encounter = new EncounterViewModel() { CampaignId = campaign.Id }; var name = await DisplayPromptAsync("New Encounter", "Name: "); if (!string.IsNullOrEmpty(name)) { encounter.Name = name; await encounter.Save(); await Navigation.PushAsync(new EncounterEditPage() { BindingContext = encounter }); } IsBusy = false; }
private async void OnSaveButtonClicked(object sender, EventArgs e) { if (IsBusy) { return; } IsBusy = true; if (App.ResourceManager.EncounterExists(encounter.Id)) { var result = await DisplayAlert("Saved Encounter", "Changing the encounter will remove the saved encounter. Continue?", "Yes", "No"); if (!result) { IsBusy = false; return; } } await encounter.Save(); Analytics.TrackEvent("Save encounter", new Dictionary <string, string> { { "encounterId", encounter.Id.ToString() } }); App.ResourceManager.RemoveEncounter(encounter); Navigation.InsertPageBefore(new EncounterDetailPage() { BindingContext = encounter }, this); await Navigation.PopAsync(); IsBusy = false; }