Esempio n. 1
0
        public static async Task <bool> ClockOut(ClockOutDto clockOutDto)
        {
            bool success = await Task.Run <bool>(async() => {
                var api = new ApiClient.ApiClient(Credentials.TruckNumber, Credentials.ApiKey);
                return(await api.ClockOutAsync(clockOutDto));
            });

            if (success)
            {
                ClockInOutState = String.Empty;
            }
            return(success);
        }
Esempio n. 2
0
        public static async Task <bool> ClockIn(ClockInDto clockInDto)
        {
            bool clockedIn = await Task.Run <bool>(async() => {
                var api = new ApiClient.ApiClient(Credentials.TruckNumber, Credentials.ApiKey);
                return(await api.ClockInAsync(clockInDto));
            });

            if (clockedIn)
            {
                ClockInOutState = "ClockOut";
            }
            return(clockedIn);
        }
Esempio n. 3
0
        /// <summary>
        /// Calls the PostRegisterTruck API in order to verify that the credentials are valid.
        /// </summary>
        /// <param name="truckCredentials"></param>
        /// <returns>the TruckDto -- TruckId > 0 for a successful login.</returns>
        public static async Task <TruckDto> VerifyCredentials(TruckDto truckCredentials)
        {
            ApiClient.ApiClient client = new ApiClient.ApiClient();
            var result = await client.RegisterTruckAsync(truckCredentials).ConfigureAwait(false);

            if (result != null)
            {
                return(result);
            }
            else
            {
                result         = new TruckDto();
                result.Message = "System or Network Error: Could not Verify the registration credentials. Please try again or report the problem if it continues.";
                result.TruckId = 0;
                return(result);
            }
        }
Esempio n. 4
0
        public static async Task <bool> GetNextJob()
        {
            bool jobChanged = false;

            if (Credentials == null || Credentials.TruckId == 0)
            {
                throw new Exception("GetNextJob requires API Credentials to be established. Restart the App and ensure your truck is registered.");
            }

            var previousJobId = CurrentJob?.JobId;

            CurrentJob = null;
            CurrentJob = await Task.Run <JobDto>(async() => {
                var api = new ApiClient.ApiClient(TripContext.Credentials.TruckNumber, TripContext.Credentials.ApiKey);
                return(await api.GetNextJobAsync(TripContext.Credentials.TruckId));
            });

            jobChanged = (previousJobId != CurrentJob?.JobId);
            return(jobChanged);
        }