public Driver_ProfilePage() { InitializeComponent(); NavigationPage.SetHasNavigationBar(this, false); _apiServices = new RestApi(); _objHeaderModel = new HeaderModel(); _baseUrl = Settings.Url + Domain.ChangePasswordApiConstant; _objChangePaswwordResponse = new ChangePaswwordResponse(); _objChnagePasswordRequest = new ChnagePasswordRequest(); BindingContext = _objChnagePasswordRequest; }
private async void BtnSubmitNewPassword_Clicked(object sender, EventArgs e) { try { var result = await DisplayAlert("Alert!", "Do you want to change your password?", "Ok", "Cancel"); // since we are using async, we should specify the DisplayAlert as awaiting. if (result == true) // if it's equal to Ok { _objChnagePasswordRequest.UserId = Settings.UserId; _objHeaderModel.TokenCode = Settings.TokenCode; if (_objChnagePasswordRequest.NewPassword != _objChnagePasswordRequest.ConfirmNewPassword) { DependencyService.Get <IToast>().Show("Confirm Password Did not Match!"); } else { _objChangePaswwordResponse = await _apiServices.ChangeOfPasswordAsync(new Get_API_Url().CommonBaseApi(_baseUrl), true, _objHeaderModel, _objChnagePasswordRequest); if (_objChangePaswwordResponse.Response.StatusCode == 200) { Settings.Password = _objChnagePasswordRequest.NewPassword; DependencyService.Get <IToast>().Show(_objChangePaswwordResponse.Response.Message); } else { DependencyService.Get <IToast>().Show(_objChangePaswwordResponse.Response.Message); } } } else // if it's equal to Cancel { return; // just return to the page and do nothing. } } catch (Exception ex) { var msg = ex.Message; } }