async private void AddEarnings(object sender, EventArgs e) { //tutti i campi devono essere compilati if (String.Equals(EarningsCategory.SelectedItem, null) || String.IsNullOrEmpty(money.Text)) { await App.Current.MainPage.DisplayAlert("Error", "Try Again", "OK"); } else if (!IsDigitsOnly(money.Text)) { await App.Current.MainPage.DisplayAlert("Error", "Insert only digits, dot or comma", "OK"); } else { string category = EarningsCategory.SelectedItem.ToString(); string moneyTrans = money.Text.Replace(',', '.'); //se valore contiene virgola viene sostituita string task = await firestore.AddTransaction(category, moneyTrans); if (String.Equals(task, "ok")) { App.Current.MainPage = new MainPage(); } else { await App.Current.MainPage.DisplayAlert("Error", "Try Again", "OK"); } } }