public static async Task<string> updateAddress(Address address) {
			OnlineRequestHandler request = new OnlineRequestHandler ();
			Task<string> result = request.SendAsyncRequest<string> ("GatewayWebapp/data/users/" + App.username + "/customer/updateAddress", address, OnlineRequestHandler.RequestType.ReqPUT);
			return await result;
		}
예제 #2
0
		private static async Task<bool> updateInfo() {
			
			titleEntry.IsEnabled = false;
			firstNameEntry.IsEnabled = false;
			lastNameEntry.IsEnabled = false;
			addressOneEntry.IsEnabled = false;
			addressTwoEntry.IsEnabled = false;
			addressTownEntry.IsEnabled = false;
			addressCountyEntry.IsEnabled = false;
			addressPostcodeEntry.IsEnabled = false;
			addressCountryPicker.IsEnabled = false;

			Address address = new Address {
				address1 = addressOneEntry.Text,
				address2 = addressTwoEntry.Text,
				city = addressTownEntry.Text,
				state = addressCountyEntry.Text,
				postcode = addressPostcodeEntry.Text
			};
			await OnlineDataLoader.updateAddress (address);
			foreach (SiteCustomerInfo s in App.siteCustomerInfo.Values) {
				s.address = address;
			}

			UserInfo current = App.userInfo;
			UserInfo newInfo = new UserInfo {
				firstName = firstNameEntry.Text,
				lastName = lastNameEntry.Text,
				title = titleEntry.Text,
				alertSubscription = current.alertSubscription,
				siteUserLinks = current.siteUserLinks,
				userID = current.userID
			};
			App.userInfo = await OnlineDataLoader.updateUserInfo (newInfo);

			titleEntry.IsEnabled = true;
			firstNameEntry.IsEnabled = true;
			lastNameEntry.IsEnabled = true;
			addressOneEntry.IsEnabled = true;
			addressTwoEntry.IsEnabled = true;
			addressTownEntry.IsEnabled = true;
			addressCountyEntry.IsEnabled = true;
			addressPostcodeEntry.IsEnabled = true;
			addressCountryPicker.IsEnabled = true;

			return true;
		}
예제 #3
0
		public AddressPage (UserInfo userInfo, Address address, CountryDropdownSet countryTree) {
			Title = "Address";
			titleEntry = new Entry {
				Text = userInfo.title,
				TextColor = Color.Black,
				HorizontalOptions = LayoutOptions.FillAndExpand
			};
			firstNameEntry = new Entry {
				Text = userInfo.firstName,
				TextColor = Color.Black,
				HorizontalOptions = LayoutOptions.FillAndExpand
			};
			lastNameEntry = new Entry {
				Text = userInfo.lastName,
				TextColor = Color.Black,
				HorizontalOptions = LayoutOptions.FillAndExpand
			};
			addressOneEntry = new Entry {
				Text = address.address1,
				TextColor = Color.Black,
				HorizontalOptions = LayoutOptions.FillAndExpand
			};
			addressTwoEntry = new Entry {
				Text = address.address2,
				TextColor = Color.Black,
				HorizontalOptions = LayoutOptions.FillAndExpand
			};
			addressTownEntry = new Entry {
				Text = address.city,
				TextColor = Color.Black,
				HorizontalOptions = LayoutOptions.FillAndExpand
			};
			addressCountyEntry = new Entry {
				Text = address.state,
				TextColor = Color.Black,
				HorizontalOptions = LayoutOptions.FillAndExpand
			};
			addressPostcodeEntry = new Entry {
				Text = address.postcode,
				TextColor = Color.Black,
				HorizontalOptions = LayoutOptions.FillAndExpand
			};
			addressCountryPicker = new Picker {	
				HorizontalOptions = LayoutOptions.FillAndExpand
			};
			CountryDropdownEntry selected = null;
			foreach (CountryDropdownEntry c in countryTree) {				
				addressCountryPicker.Items.Add (c.name);
				if (c.code.Equals (address.country)) {
					selected = c;
				}
			}

			addressCountryPickerTest = new ExtendedPicker {
				//ItemsSource = countryTree,
				SelectedItem = selected,
				DisplayProperty = "name",
				HorizontalOptions = LayoutOptions.FillAndExpand				
			};

			//if (!String.IsNullOrWhiteSpace (selected)) {
			//	for (int i = 0; i < addressCountryPicker.Items.Count - 1; i++) {
			//		if (addressCountryPicker.Items [i].Equals (selected)) {
			//			addressCountryPicker.SelectedIndex = i;
			//		}
			//	}
			//}
				
			titleEntry.Completed += async (sender, e) => await updateInfo ();
			firstNameEntry.Completed += async (sender, e) => await updateInfo();
			lastNameEntry.Completed += async (sender, e) => await updateInfo();
			addressOneEntry.Completed += async (sender, e) => await updateInfo();
			addressTwoEntry.Completed += async (sender, e) => await updateInfo();
			addressTownEntry.Completed += async (sender, e) => await updateInfo();
			addressCountyEntry.Completed += async (sender, e) => await updateInfo();
			addressPostcodeEntry.Completed += async (sender, e) => await updateInfo();
			addressCountryPicker.SelectedIndexChanged += async (sender, e) => await updateInfo();
			addressCountryPickerTest.SelectedIndexChanged += async (sender, e) => await updateInfo();
		}
예제 #4
0
		public static async Task<AddressPage> CreateAddressPage(UserInfo userInfo, Address address) {

			CountryDropdownSet countryMap = await OnlineDataLoader.getCountryDropdown ();
			AddressPage addressPage = new AddressPage (userInfo, address, countryMap);

			Label titleLabel = new Label {
				Text = "Title",
				TextColor = Color.Gray,
				HorizontalOptions = LayoutOptions.FillAndExpand
			};
			Label firstNameLabel = new Label {
				Text = "First name",
				TextColor = Color.Gray,
				HorizontalOptions = LayoutOptions.FillAndExpand
			};
			Label lastNameLabel = new Label {
				Text = "Last name",
				TextColor = Color.Gray,
				HorizontalOptions = LayoutOptions.FillAndExpand
			};
			Label addressOneLabel = new Label {
				Text = "Address 1",
				TextColor = Color.Gray,
				HorizontalOptions = LayoutOptions.FillAndExpand
			};
			Label addressTwoLabel = new Label {
				Text = "Address 2",
				TextColor = Color.Gray,
				HorizontalOptions = LayoutOptions.FillAndExpand
			};
			Label addressTownLabel = new Label {
				Text = "Town/City",
				TextColor = Color.Gray,
				HorizontalOptions = LayoutOptions.FillAndExpand
			};
			Label addressCountyLabel = new Label {
				Text = "County/State/Province",
				TextColor = Color.Gray,
				HorizontalOptions = LayoutOptions.FillAndExpand
			};
			Label addressPostcodeLabel = new Label {
				Text = "Postcode",
				TextColor = Color.Gray,
				HorizontalOptions = LayoutOptions.FillAndExpand
			};
			Label addressCountryLabel = new Label {
				Text = "Country",
				TextColor = Color.Gray,
				HorizontalOptions = LayoutOptions.FillAndExpand
			};

			StackLayout layout = new StackLayout {
				VerticalOptions = LayoutOptions.FillAndExpand,
				HorizontalOptions = LayoutOptions.FillAndExpand,
				Padding = new Thickness(20),
				BackgroundColor = Color.White,
				Children = {
					titleLabel,
					titleEntry,
					firstNameLabel,
					firstNameEntry,
					lastNameLabel,
					lastNameEntry,
					addressOneLabel, addressOneEntry,addressTwoLabel, addressTwoEntry,addressTownLabel, addressTownEntry,addressCountyLabel, addressCountyEntry,addressPostcodeLabel, addressPostcodeEntry,
					addressCountryLabel, addressCountryPicker
				}
			};
			ScrollView scrollView = new ScrollView {
				Content = layout
			};

			addressPage.Content = scrollView;
			return addressPage;

		}