Exemplo n.º 1
0
 public async void RegisterApp()
 {
     if (CrossConnectivity.Current.IsConnected)
     {
         await DeviceInfoHandler.UpdateDeviceInfo(
             (response) =>
         {
             IsRegistered = true;
         },
             (errorResponse) =>
         {
             Debug.WriteLine("Device not registered.");
         }
             );
     }
 }
Exemplo n.º 2
0
 public async void DoLogin()
 {
     if (IsValidData())
     {
         if (CrossConnectivity.Current.IsConnected)
         {
             IsBusy = true;
             if (!App.IsRegistered)
             {
                 DeviceInfoHandler.UpdateDeviceInfo((response) =>
                 {
                     Debug.WriteLine("Device info updated.");
                     App.IsRegistered = true;
                 });
             }
             await UserHandler.GetLogin(UserName, Password,
                                        (response) => {
                 try {
                     Debug.WriteLine("success:" + response.UniqueAppId);
                     App.UserName    = UserName;
                     App.UniqueAppId = response.UniqueAppId;
                     Settings.Local.Set("IsLogin", true);
                     IsBusy = false;
                     // NavigationHandler.GlobalNavigator.Navigation.PopAsync(); //Navigate to main page after successful login
                     SetupUpdatePwdPage _ChangePassword = new SetupUpdatePwdPage();
                     _ChangePassword.BindingContext     = new ProfileViewModel();
                     NavigationHandler.LoginNavigator.Navigation.PushAsync(_ChangePassword);      //navigate to update password page
                 } catch (Exception e) {
                     Debug.WriteLine("Exception is " + e.Message + " \n source: " + e.Source + " call stack :" + e.StackTrace);
                 }
             },
                                        (errorResponse) => {
                 NavigationHandler.LoginNavigator.DisplayAlert(Constants.APP_NAME, Constants.LoginUnSuccess, Constants.OK_TEXT);
                 IsBusy = false;
             });
         }
         else
         {
             NavigationHandler.LoginNavigator.DisplayAlert(Constants.APP_NAME, Constants.NETWORK_ERROR, Constants.OK_TEXT);
         }
     }
     else
     {
         if (string.IsNullOrEmpty(UserName) && string.IsNullOrEmpty(Password))
         {
             ErrorColor = Color.Red;
             ValidColor = Color.Red;
         }
         else if (string.IsNullOrEmpty(Password))
         {
             ErrorColor = Color.Red;
         }
         else if (string.IsNullOrEmpty(UserName))
         {
             ValidColor = Color.Red;
         }
         else
         {
             ValidColor = Color.FromRgb(97, 97, 97);
             ErrorColor = Color.FromRgb(97, 97, 97);
         }
         NavigationHandler.LoginNavigator.DisplayAlert(Constants.APP_NAME, Constants.InSuccess, Constants.OK_TEXT);
     }
 }