private async Task Submit() { try { this.IsBusy = true; if (this.Height <= 0) { await App.Current.MainPage.DisplayAlert("Alert", "Please insert Height valid value", "OK"); return; } if (this.Weight <= 0) { await App.Current.MainPage.DisplayAlert("Alert", "Please insert Weight valid value", "OK"); return; } if (this.Age <= 0) { await App.Current.MainPage.DisplayAlert("Alert", "Please insert Age valid value", "OK"); return; } if (string.IsNullOrWhiteSpace(this.SelectedGenderItem)) { await App.Current.MainPage.DisplayAlert("Alert", "Please Select Gender Value", "OK"); return; } BodyMetrics bodyMetrics = new BodyMetrics { weight = new Weight { value = this.Weight, unit = "kg" }, height = new Height { value = this.Height, unit = "cm" }, sex = SelectedGenderItem == "Male" ? "m" : "f", age = this.Age, hip = this.Hip, waist = this.Waist }; BMIApiResponse res = await BMIApiClient.Instance.PostBMI(bodyMetrics); await App.Current.MainPage.Navigation.PushAsync(new BMIResult(res), true); } catch (Exception ex) { await App.Current.MainPage.DisplayAlert("Error", ex.Message, "OK"); } finally { this.IsBusy = false; } }
public BMIResult(BMIApiResponse result) { InitializeComponent(); this.BindingContext = result; }