コード例 #1
0
        private async void submitBtn_Clicked(object sender, EventArgs e)
        {
            string  price = priceEnt.Text;
            Request request;

            try
            {
                request = new Request()
                {
                    title         = jobtitleent.Text,
                    description   = DescriptionEnt.Text,
                    contactMethod = contactMethodMap[ContactEnt.SelectedItem.ToString()],
                    skill         = skillMap[SkillEnt.SelectedItem.ToString()],
                    priceInCents  = parsePrice(priceEnt.Text),
                };
            }
            catch (FormatException ex)
            {
                DisplayAlert("Invalid price", "Please enter a valid price.", "OK");
                return;
            }
            var json    = JsonConvert.SerializeObject(request);
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            HttpClient client = HttpAuthHandler.addTokenHeader(new HttpClient());

            var result = await client.PostAsync(HttpAuthHandler.API_URL + "api/Request/", content);

            if (result.StatusCode == HttpStatusCode.Created)
            {
                await DisplayAlert("Your help request has been sent", "A Wizard will reach out to you shortly", "Horray!");
            }

            await Navigation.PopToRootAsync();
        }
コード例 #2
0
        private async void approveButton_Clicked(object sender, EventArgs e)
        {
            HttpClient client = HttpAuthHandler.addTokenHeader(new HttpClient());

            HttpResponseMessage response = await client.PutAsync(HttpAuthHandler.API_URL + "api/Request/" + thisRequest.requestID, null);

            if (response.IsSuccessStatusCode && bool.Parse(await response.Content.ReadAsStringAsync()))
            {
                await DisplayAlert("Job Approved!", "This is where payment logic would go.", "Ok");

                approvalHeader.IsVisible = false;
                approvalGrid.IsVisible   = false;

                thisRequest.completedDate = DateTime.Now;

                jobDateCompletedHeaderLabel.IsVisible = true;
                jobDateCompletedLabel.IsVisible       = true;
                jobDateCompletedLabel.Text            = thisRequest.completedDate.Value.ToString("MMMM d, yyyy") +
                                                        " (" + calculateDaysAgo(thisRequest.completedDate.Value) + ")";

                jobStatusLabel.BackgroundColor = Color.FromHex(thisRequest.statusColor);
                jobStatusLabel.Text            = thisRequest.status;
            }
            else
            {
                await DisplayAlert("Error!", "Something went wrong processing your request.  Please try again later", "Ok");
            }
        }
コード例 #3
0
        private async void acceptButton_Clicked(object sender, EventArgs e)
        {
            bool confirmed = await DisplayAlert("Are you sure?", "Would you like to accept this " + thisRequest.skill + " job for " + thisRequest.formattedPrice + " per hour?", "Yes", "No");

            if (confirmed)
            {
                HttpClient client = HttpAuthHandler.addTokenHeader(new HttpClient());

                HttpResponseMessage requestsResponse = await client.PostAsync(HttpAuthHandler.API_URL + "api/WizardJob/" + thisRequest.requestID, null);


                if (requestsResponse.IsSuccessStatusCode && bool.Parse(await requestsResponse.Content.ReadAsStringAsync()))
                {
                    await DisplayAlert("Job Accepted!", "Check your orders page for the job info!", "Ok");

                    thisRequest.acceptDate = DateTime.Now;

                    Navigation.PopAsync();
                }
                else
                {
                    await DisplayAlert("Error!", "Something went wrong processing your request.  Please try again later", "Ok");
                }
            }
        }
コード例 #4
0
ファイル: Jobs.xaml.cs プロジェクト: holtcl/TechWizard
        private async void populateJobs()
        {
            HttpClient client = new HttpClient();

            client = HttpAuthHandler.addTokenHeader(client);

            var requestsResponse = await client.GetAsync(HttpAuthHandler.API_URL + "api/Request");

            if (requestsResponse.IsSuccessStatusCode)
            {
                string data = await requestsResponse.Content.ReadAsStringAsync();

                JobsForDisplay             = JsonConvert.DeserializeObject <List <JobListObject> >(data);
                collectionView.ItemsSource = JobsForDisplay;
            }
        }
コード例 #5
0
        private async void saveButton_Clicked(object sender, EventArgs e)
        {
            HttpClient client = HttpAuthHandler.addTokenHeader(new HttpClient());

            HttpResponseMessage response = await client.PutAsync(HttpAuthHandler.API_URL + "api/WizardJob/" + thisRequest.requestID + "/" + hoursWorkedEnt.Text, null);

            if (response.IsSuccessStatusCode && bool.Parse(await response.Content.ReadAsStringAsync()))
            {
                await DisplayAlert("Job Accepted!", "Please wait for your client to accept the Hours.", "Ok");

                hoursWorkedEnt.IsEnabled = false;
                saveButton.IsVisible     = false;
                thisRequest.hours        = int.Parse(hoursWorkedEnt.Text);
                jobStatusLabel.Text      = thisRequest.status;
            }
            else
            {
                await DisplayAlert("Error!", "Something went wrong processing your request.  Please try again later", "Ok");
            }
        }
コード例 #6
0
        private async void populateDropdowns()
        {
            HttpClient client = new HttpClient();

            client = HttpAuthHandler.addTokenHeader(client);

            var skillsResponse = await client.GetAsync(HttpAuthHandler.API_URL + "api/Skills");

            var contactMethodsResponse = await client.GetAsync(HttpAuthHandler.API_URL + "api/contactMethods");

            if (skillsResponse.IsSuccessStatusCode)
            {
                string data = await skillsResponse.Content.ReadAsStringAsync();

                Skill[] skills = JsonConvert.DeserializeObject <Skill[]>(data);

                foreach (Skill skill in skills)
                {
                    SkillEnt.Items.Add(skill.name);
                    skillMap.Add(skill.name, skill.id);
                }
            }

            if (contactMethodsResponse.IsSuccessStatusCode)
            {
                string data = await contactMethodsResponse.Content.ReadAsStringAsync();

                ContactMethod[] contactMethods = JsonConvert.DeserializeObject <ContactMethod[]>(data);

                foreach (ContactMethod contactMethod in contactMethods)
                {
                    ContactEnt.Items.Add(contactMethod.MethodName);
                    contactMethodMap.Add(contactMethod.MethodName, contactMethod.id);
                }
            }
        }