Esempio n. 1
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");
            }
        }
Esempio n. 2
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);
                }
            }
        }
Esempio n. 3
0
 private async void Logout_Clicked(object sender, EventArgs e)
 {
     await HttpAuthHandler.logout();
 }
Esempio n. 4
0
        private async void SignUpButton_OnClicked(object sender, EventArgs e)
        {
            if (!isValidEmail(EmailEnt.Text))
            {
                await DisplayAlert("Error", "Email is not valid.", "OK");

                return;
            }

            //todo: validate zip


            //todo: validate phone


            //todo: validate password


            //todo: validate zip


            User user = new User()
            {
                UserName  = EmailEnt.Text,
                FirstName = FirstNameEnt.Text,
                LastName  = LastNameEnt.Text,
                Address   = Address_ent.Text,
                City      = City_ent.Text,
                State     = state_ent.SelectedItem.ToString(),
                Zip       = Int32.Parse(zip_ent.Text),
                Email     = EmailEnt.Text,
                Phone     = Phone_ent.Text,
                Password  = PasswordEnt.Text
            };


            var json    = JsonConvert.SerializeObject(user);
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            HttpClient client = new HttpClient();

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

            var loginsuccess = await HttpAuthHandler.login(user.UserName, user.Password);

            if (result.StatusCode == HttpStatusCode.Created && loginsuccess)
            {
                await DisplayAlert("Success", "Your account has been created", "Find a Wizard");

                Profile profile = new Profile();
                Application.Current.MainPage = new NavigationPage(profile);
            }
            else
            {
                await DisplayAlert("Error", result.StatusCode + result.ReasonPhrase, "ok");
            }



            //await Navigation.PushAsync(new Profile());
        }