async void SignInProcedure(object sender, EventArgs e) { try { (sender as Button).IsEnabled = false; UserDialogs.Instance.ShowLoading("Please Wait..."); this.IsEnabled = false; UserAccount user = new UserAccount(Entry_Username.Text, Entry_Password.Text); if (user.CheckInformation()) { var loginResponse = await App.RestService.PostResponse_HTTPRESPONSE(Constants.APIURL + "useraccount/login", JsonConvert.SerializeObject(user)); if (loginResponse.StatusCode == System.Net.HttpStatusCode.OK) { string jsonResult = await loginResponse.Content.ReadAsStringAsync(); var userAccount = JsonConvert.DeserializeObject <UserAccount>(jsonResult); App.UserDatabase.SaveUser(userAccount); Application.Current.MainPage = new NavigationPage(new CustomerTabbedPage()); } else { await DisplayAlert("Login Failed", "Login credentials not correct or something went wrong", "Ok"); UserDialogs.Instance.HideLoading(); (sender as Button).IsEnabled = true; this.IsEnabled = true; } } else { await DisplayAlert("Login Failed", "Entered value not valid", "Ok"); try { UserDialogs.Instance.HideLoading(); } catch (Exception ex) { } (sender as Button).IsEnabled = true; this.IsEnabled = true; } } catch (Exception ex) { await DisplayAlert("Login Failed", "Something went wrong check your connection", "Ok"); try { UserDialogs.Instance.HideLoading(); } catch (Exception eex) { } } (sender as Button).IsEnabled = true; this.IsEnabled = true; }