Example #1
0
        private async Task SetInitialViewModelAsync()
        {
            var customerRepository     = _repositories.CustomerRepository;
            var customerRepositoryData = await customerRepository.GetAllAsync();

            if (customerRepositoryData.Any())
            {
                var appProfile = await _repositories.ApplicationRepository.GetAsync();

                if (appProfile.DeviceCheckInOutRequired)
                {
                    IsBusy = true;
                    CheckInOutService       service = new CheckInOutService(_repositories);
                    Enums.CheckInOutActions status  = await service.GetDeviceStatus(Mvx.Resolve <IDeviceInfo>().IMEI);

                    if (status == Enums.CheckInOutActions.CheckIn)
                    {
                        this.SetInitialViewModel <CheckOutViewModel>();
                    }
                    else
                    {
                        this.SetInitialViewModel <PasscodeViewModel>();
                    }
                    IsBusy = false;
                }
                else
                {
                    this.SetInitialViewModel <PasscodeViewModel>();
                }
            }
            else
            {
                this.SetInitialViewModel <CustomerCodeViewModel>();
            }
        }
Example #2
0
        public async Task CheckInDeviceAsync()
        {
            IsBusy = true;
            NavData <Models.CheckInOutData> navData = _navigationService.CurrentNavData as NavData <Models.CheckInOutData>;

            navData.Data.actualActionPerformed = CheckInOutActions.CheckIn;
            navData.Data.actualIMEI            = Mvx.Resolve <IDeviceInfo>().IMEI;
            navData.Data.signature             = string.Empty;
            navData.Data.driverName            = string.Empty;

            CheckInOutService service = new CheckInOutService(_repositories);
            HttpResult        result  = await service.CheckInDevice(navData.Data);

            IsBusy = false;
            if (result.Succeeded)
            {
                Status = "Device successfully checked in.";
                Task.Delay(1000).ContinueWith((x) => ShowViewModel <CheckOutViewModel>());
            }
            else if (result.StatusCode == System.Net.HttpStatusCode.NotAcceptable)
            {
                Status = "The QR code data and device details did not match. Please ensure that you are checking in the correct device.";
            }
            else if (result.StatusCode == System.Net.HttpStatusCode.InternalServerError)
            {
                Status = "Could not complete Check In process because of server error. Please try again later.";
            }
            else
            {
                Status = "Unable to communicate with Device management. Please ensure mobile data is ON.";
            }
        }
        public async Task MoveToNextAsync()
        {
            if (string.IsNullOrEmpty(DriverName) || string.IsNullOrWhiteSpace(DriverName))
            {
                await Mvx.Resolve <ICustomUserInteraction>().AlertAsync("To complete, please enter your name");
            }

            if (string.IsNullOrEmpty(DriverSignature) || string.IsNullOrWhiteSpace(DriverSignature))
            {
                await Mvx.Resolve <ICustomUserInteraction>().AlertAsync("To continue, please sign on the pad");
            }

            if (!string.IsNullOrEmpty(DriverName) && !string.IsNullOrWhiteSpace(DriverName) &&
                !string.IsNullOrEmpty(DriverSignature) && !string.IsNullOrWhiteSpace(DriverSignature))
            {
                IsBusy = true;
                NavData <Models.CheckInOutData> navData = _navigationService.CurrentNavData as NavData <Models.CheckInOutData>;
                navData.Data.actualActionPerformed = CheckInOutActions.CheckOut;
                navData.Data.actualIMEI            = Mvx.Resolve <IDeviceInfo>().IMEI;
                navData.Data.signature             = DriverSignature;
                navData.Data.driverName            = DriverName;

                CheckInOutService service = new CheckInOutService(_repositories);
                HttpResult        result  = await service.CheckOutDevice(navData.Data);

                IsBusy = false;
                if (result.Succeeded)
                {
                    await _navigationService.MoveToNextAsync();
                }
                else if (result.StatusCode == System.Net.HttpStatusCode.NotAcceptable)
                {
                    await Mvx.Resolve <ICustomUserInteraction>().AlertAsync(
                        "The QR code data and device details did not match. Please ensure that you are checking out the correct device.");
                }
                else if (result.StatusCode == System.Net.HttpStatusCode.InternalServerError)
                {
                    await Mvx.Resolve <ICustomUserInteraction>().AlertAsync(
                        "Could not complete Check out process because of server error. Please try again later.");
                }
                else
                {
                    await Mvx.Resolve <ICustomUserInteraction>().AlertAsync(
                        "Unable to communicate with Device management. Please ensure mobile data is ON.");
                }
            }
        }
Example #4
0
        public async Task CheckInDeviceAsync()
        {
            ProgressTitle   = _progressTitleForCheckIn;
            ProgressMessage = _progressMessageForCheckIn;
            IsBusy          = true;

            CheckInOutService service = new CheckInOutService(_repositories);
            CheckInOutActions status  = await service.GetDeviceStatus(Mvx.Resolve <IDeviceInfo>().IMEI);

            IsBusy = false;
            if (status == CheckInOutActions.CheckOut)
            {
                ShowViewModel <CheckInViewModel>();
            }
            else
            {
                await Mvx.Resolve <ICustomUserInteraction>().AlertAsync("This device is not checked out, so can not be checked in.");
            }
        }