You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.5 KiB

1 year ago
  1. using GMCabsDriverAssistant.Services;
  2. using GMCabsDriverAssistantSolution.Views;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace GMCabsDriverAssistantSolution.ViewModels
  9. {
  10. class AdminPasswordViewModel : BaseViewModel
  11. {
  12. #region Fields
  13. private string adminPassword;
  14. private string message;
  15. #endregion
  16. #region Properties
  17. public Command ContinueCommand { get; }
  18. public Command BackCommand { get; }
  19. public string AdminPassword
  20. {
  21. get => adminPassword;
  22. set
  23. {
  24. SetProperty(ref adminPassword, value);
  25. ErrorMessage = string.Empty;
  26. }
  27. }
  28. public string ErrorMessage
  29. {
  30. get => message;
  31. set => SetProperty(ref message, value);
  32. }
  33. #endregion
  34. #region Constructor
  35. public AdminPasswordViewModel()
  36. {
  37. ContinueCommand = new Command(OnContinueClicked);
  38. BackCommand = new Command(OnBackClicked);
  39. }
  40. #endregion
  41. #region Methods
  42. [Obsolete]
  43. private async void OnContinueClicked(object obj)
  44. {
  45. IsBusy = true;
  46. ErrorMessage = "";
  47. GMCabsDriverService gmCabsDriverService = new GMCabsDriverService();
  48. if (string.IsNullOrWhiteSpace(AdminPassword))
  49. {
  50. IsBusy = false;
  51. ErrorMessage = "Admin Password required";
  52. return;
  53. }
  54. var isValid = await gmCabsDriverService.ValidateAdminPassword(AdminPassword);
  55. if (isValid)
  56. {
  57. IsBusy = false;
  58. if (Device.RuntimePlatform == Device.Android && Device.Idiom == TargetIdiom.Tablet)
  59. {
  60. await Shell.Current.GoToAsync($"//{nameof(LoginPage)}/{nameof(AdminPasswordPage)}/{nameof(ImeiNumberInstallPage)}");
  61. }
  62. else
  63. {
  64. await Shell.Current.GoToAsync($"//{nameof(LoginPage)}/{nameof(AdminPasswordPage)}/{nameof(TaxiInstallPage)}");
  65. }
  66. }
  67. else
  68. {
  69. IsBusy = false;
  70. ErrorMessage = "Password is not match";
  71. }
  72. }
  73. private async void OnBackClicked(object obj)
  74. {
  75. ErrorMessage = "";
  76. await Shell.Current.GoToAsync("..");
  77. }
  78. #endregion
  79. }
  80. }