async void Login() { if (IBRemeberMeBtn.Selected) { IosUtils.Settings.IsRememberMeSelected = true; IosUtils.Settings.UserName = IBUsernameTxt.Text; IosUtils.Settings.Password = IBPasswordTxt.Text; } else { IosUtils.Settings.RemoveLoginInfo(); } if (IosUtils.IosUtility.IsReachable()) { IosUtils.IosUtility.showProgressHud(""); var loginResponse = await WebServiceMethods.Login(IBUsernameTxt.Text, IBPasswordTxt.Text); IosUtils.IosUtility.hideProgressHud(); if (loginResponse != null) { if (loginResponse.IsAuthenticate) { IosUtils.Settings.UserId = loginResponse.UserId; IosUtils.Settings.IsLogedin = true; IosUtils.Settings.Name = loginResponse.Name; IosUtils.Settings.UserMail = loginResponse.UserEmail; IosUtils.Settings.UserCompCode = loginResponse.UserCompCode; AppDelegate.GetSharedInstance().showHomeScreen(); } else { IosUtils.IosUtility.showAlertWithInfo(IosUtils.LocalizedString.sharedInstance.GetLocalizedString("LSErrorTitle", ""), IosUtils.LocalizedString.sharedInstance.GetLocalizedString("LSInvalidCredentialError", "")); } } else { //AppDelegate.GetSharedInstance().showHomeScreen(); IosUtils.IosUtility.showAlertWithInfo(IosUtils.LocalizedString.sharedInstance.GetLocalizedString("LSErrorTitle", ""), IosUtils.LocalizedString.sharedInstance.GetLocalizedString("LSInvalidCredentialError", "")); } } }
private async void Button_Click(object sender, System.EventArgs e) { try { if (CrossConnectivity.Current.IsConnected) { CustomProgressDialog.ShowProgDialog(mActivity, Resources.GetString(Resource.String.loading)); username = edt_username.Text; password = edt_password.Text; int selectedRadioBtnId = radio_group.CheckedRadioButtonId; RadioButton radioBtn = FindViewById <RadioButton>(selectedRadioBtnId); if (ValidateForm()) { if (chk_remember_me.Checked) { mSharedPreferencesManager.PutString(ConstantsDroid.USERNAME_PREFERENCE, username); mSharedPreferencesManager.PutString(ConstantsDroid.PASSWORD_PREFERENCE, password); mSharedPreferencesManager.PutString(ConstantsDroid.DATABASE_PREFERENCE, radioBtn.Text); } else { mSharedPreferencesManager.PutString(ConstantsDroid.USERNAME_PREFERENCE, ""); mSharedPreferencesManager.PutString(ConstantsDroid.PASSWORD_PREFERENCE, ""); } //UtilityDroid.GetInstance().ShowToast(mActivity, "Before Print", ToastLength.Long); LoginResponse loginResponse = await WebServiceMethods.Login(username, password); //UtilityDroid.GetInstance().ShowToast(mActivity, "After Print"+ finalResponse.StatusCode, ToastLength.Long); if (loginResponse != null) { if (loginResponse.IsAuthenticate) { mSharedPreferencesManager.PutLoginResponse(loginResponse); mSharedPreferencesManager.PutString(ConstantsDroid.USER_ID_PREFERENCE, loginResponse.UserId); CustomProgressDialog.HideProgressDialog(); StartActivity(new Intent(this, typeof(HomeActivity))); OverridePendingTransition(Resource.Animation.animation_enter, Resource.Animation.animation_leave); Finish(); } else { CustomProgressDialog.HideProgressDialog(); UtilityDroid.GetInstance().ShowAlertDialog(mActivity, Resources.GetString(Resource.String.error_alert_title), Resources.GetString(Resource.String.alert_message_invalid_credentials), Resources.GetString(Resource.String.alert_cancel_btn), Resources.GetString(Resource.String.alert_ok_btn)); } } else { CustomProgressDialog.HideProgressDialog(); UtilityDroid.GetInstance().ShowAlertDialog(mActivity, Resources.GetString(Resource.String.error_alert_title), Resources.GetString(Resource.String.alert_message_invalid_credentials), Resources.GetString(Resource.String.alert_cancel_btn), Resources.GetString(Resource.String.alert_ok_btn)); } } else { CustomProgressDialog.HideProgressDialog(); UtilityDroid.GetInstance().ShowAlertDialog(mActivity, Resources.GetString(Resource.String.error_alert_title), Resources.GetString(Resource.String.alert_message_enter_username_and_password), Resources.GetString(Resource.String.alert_cancel_btn), Resources.GetString(Resource.String.alert_ok_btn)); } } else { UtilityDroid.GetInstance().ShowAlertDialog(mActivity, Resources.GetString(Resource.String.error_alert_title), Resources.GetString(Resource.String.alert_message_no_network_connection), Resources.GetString(Resource.String.alert_cancel_btn), Resources.GetString(Resource.String.alert_ok_btn)); } } catch (Exception) { CustomProgressDialog.HideProgressDialog(); UtilityDroid.GetInstance().ShowAlertDialog(mActivity, Resources.GetString(Resource.String.error_alert_title), Resources.GetString(Resource.String.alert_message_invalid_credentials), Resources.GetString(Resource.String.alert_cancel_btn), Resources.GetString(Resource.String.alert_ok_btn)); } }