private async void CheckAssignment(string theID)
        {
            try
            {
                JobRequests jobRequests = new JobRequests();

                string url = $"http://ijobapp.azurewebsites.net/api/CheckAssigned?ClientID={theID}";

                HttpClient client = new HttpClient();
                string     json   = await client.GetStringAsync(url);

                //ConfigureAwait(false);
                JobRequests jobRequestss = JsonConvert.DeserializeObject <JobRequests>(json);
                if (jobRequestss != null)
                {
                    // await Navigation.PushAsync(new HomePage());

                    jobRequests.ClientID       = jobRequestss.ClientID;
                    jobRequests.Date           = jobRequestss.Date;
                    jobRequests.TimeStart      = jobRequestss.TimeStart;
                    jobRequests.TimeEnd        = jobRequestss.TimeEnd;
                    jobRequests.Category       = jobRequestss.Category;
                    jobRequests.NumOfLabs      = jobRequestss.NumOfLabs;
                    jobRequests.JobSpec        = jobRequestss.JobSpec;
                    jobRequests.Location       = jobRequestss.Location;
                    jobRequests.TranspotStatus = jobRequestss.TranspotStatus;
                    jobRequests.IsAssigned     = jobRequestss.IsAssigned;
                    jobRequests.Cost           = jobRequestss.Cost;

                    if (jobRequests.IsAssigned == true)
                    {
                        if (Client.isDriving == true)
                        {
                            //Navigate to Map
                        }
                        else if (Client.isDriving == false)
                        {
                            await DisplayAlert("Job Assigned", "Your job has been assigned, Please be patient while we transport your labourer/s", "Ok");

                            await Navigation.PushAsync(new JobInProgressPage());

                            Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]);
                            istimerOn = false;
                            //Navigate to map
                        }
                    }
                    else if (jobRequests.IsAssigned == false)
                    {
                    }
                }
                else
                {
                    await DisplayAlert("No Job request found", $"There is no request that is reflecting in the syste, ", "Ok");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Try again", ex.Message, "OK");
            }
        }
Exemplo n.º 2
0
        private async void BtnClick_Clicked(object sender, EventArgs e)
        {
            //CheckStatus(txtInput.Text);
            //DisplayAlert("test",isJobassigned.ToString(),"ok");
            try
            {
                JobRequests jobRequests = new JobRequests();

                string url = $"http://ijobapp.azurewebsites.net/api/CheckAssigned?ClientID={txtInput.Text}";

                HttpClient client = new HttpClient();
                string     json   = await client.GetStringAsync(url);

                //ConfigureAwait(false);
                JobRequests jobRequestss = JsonConvert.DeserializeObject <JobRequests>(json);
                if (jobRequestss != null)
                {
                    // await Navigation.PushAsync(new HomePage());

                    jobRequests.ClientID       = jobRequestss.ClientID;
                    jobRequests.Date           = jobRequestss.Date;
                    jobRequests.TimeStart      = jobRequestss.TimeStart;
                    jobRequests.TimeEnd        = jobRequestss.TimeEnd;
                    jobRequests.Category       = jobRequestss.Category;
                    jobRequests.NumOfLabs      = jobRequestss.NumOfLabs;
                    jobRequests.JobSpec        = jobRequestss.JobSpec;
                    jobRequests.Location       = jobRequestss.Location;
                    jobRequests.TranspotStatus = jobRequestss.TranspotStatus;
                    jobRequests.IsAssigned     = jobRequestss.IsAssigned;
                    jobRequests.Cost           = jobRequestss.Cost;

                    if (jobRequests.IsAssigned == true)
                    {
                        await DisplayAlert("In", "We are in", "OK");
                    }
                    else if (jobRequests.IsAssigned == false)
                    {
                        await DisplayAlert("Out", "We are out", "OK");
                    }
                }
                else
                {
                    await DisplayAlert("No Job request like that Failed", $"Hakuna request yakadaro ", "Ok");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Try again", ex.Message, "OK");
            }
        }