public async void Login() { //TEST INTERNET CONNECTTION var httpClient = new HttpClient(); try { var testInternet = await httpClient.GetStringAsync(ServerDatabase.localhost + "store/getstorebyid/test"); } catch (Exception ex) { await App.Current.MainPage.DisplayAlert("Error", "Action fail, check your internet connection and try again!", "OK"); return; } DataProvider dataProvider = DataProvider.GetInstance(); Preferences.Set("UsernameLogin", Username); Preferences.Set("PasswordLogin", Password); if (Remember) { Preferences.Set("Username", Username); Preferences.Set("Password", Password); Preferences.Set("Remember", true); } else { Preferences.Set("Username", ""); Preferences.Set("Password", ""); Preferences.Set("Remember", false); } try { using (UserDialogs.Instance.Loading("Waiting..")) { while (Database.Users.Count == 0) { await LoadServerDataAsync(); } if (!dataProvider.CheckAccountExist(this.Username, this.Password)) { OneSignal.Current.SetExternalUserId(""); await LoginView.GetInstance().DisplayAlert("Account not exist", "Wrong username or password, please try again", "OK"); return; } await App.Current.MainPage.Navigation.PushAsync(new MiddleView(Username, Password), true); } } catch (Exception e) { UserDialogs.Instance.HideLoading(); HandleException.BeforeLogin(); return; } }
public async void Register() { try { using (UserDialogs.Instance.Loading("Waiting..")) { await LoadServerDataAsync(); await App.Current.MainPage.Navigation.PushAsync(new RegisterView(), true); } } catch { UserDialogs.Instance.HideLoading(); HandleException.BeforeLogin(); return; } }
public async void ResetPassword() { try { using (UserDialogs.Instance.Loading("Waiting..")) { await LoadServerDataAsync(); await App.Current.MainPage.Navigation.PushAsync(new EmailVerifyView()); } } catch (Exception e) { UserDialogs.Instance.HideLoading(); HandleException.BeforeLogin(); return; } }