using GMCabsDriverAssistant.Services;
|
|
using GMCabsDriverAssistantSolution.Views;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace GMCabsDriverAssistantSolution.ViewModels
|
|
{
|
|
class TaxiInstallViewModel : BaseViewModel
|
|
{
|
|
#region Fields
|
|
private string taxiNumber;
|
|
private string message;
|
|
#endregion
|
|
|
|
#region Properties
|
|
public Command SaveCommand { get; }
|
|
public Command BackCommand { get; }
|
|
public string TaxiNumber
|
|
{
|
|
get => taxiNumber;
|
|
set
|
|
{
|
|
SetProperty(ref taxiNumber, value);
|
|
ErrorMessage = string.Empty;
|
|
}
|
|
}
|
|
public string ErrorMessage
|
|
{
|
|
get => message;
|
|
set => SetProperty(ref message, value);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
public TaxiInstallViewModel()
|
|
{
|
|
SaveCommand = new Command(OnSaveClicked);
|
|
BackCommand = new Command(OnBackClicked);
|
|
}
|
|
#endregion
|
|
|
|
#region Methods
|
|
private async void OnSaveClicked(object obj)
|
|
{
|
|
IsBusy = true;
|
|
ErrorMessage = "";
|
|
GMCabsDriverService gmCabsDriverService = new GMCabsDriverService();
|
|
if (string.IsNullOrWhiteSpace(TaxiNumber))
|
|
{
|
|
IsBusy = false;
|
|
ErrorMessage = "Taxi Number required";
|
|
return;
|
|
}
|
|
var isValidTaxinumberInstallation = await gmCabsDriverService.ValidateTaxiNumberInstallation(TaxiNumber);
|
|
if (isValidTaxinumberInstallation)
|
|
{
|
|
Preferences.Set("taxiNumber", TaxiNumber.ToString());
|
|
IsBusy = false;
|
|
await Shell.Current.GoToAsync($"//{nameof(LoginPage)}/{nameof(AdminPasswordPage)}/{nameof(TaxiInstallPage)}/{nameof(InstallCompletePage)}");
|
|
}
|
|
else
|
|
{
|
|
IsBusy = false;
|
|
ErrorMessage = "Taxi number not valid";
|
|
}
|
|
}
|
|
private async void OnBackClicked(object obj)
|
|
{
|
|
ErrorMessage = "";
|
|
await Shell.Current.GoToAsync("..");
|
|
}
|
|
#endregion
|
|
|
|
|
|
}
|
|
}
|