//Upload a symbolicLocation in the background (update or create)
	    //Form: AsyncTask<[Input Parameter Type], [Progress Report Type], [Result Type]>
	    private void UploadSymbolicLocationTask(SymbolicLocation tmpSymLoc)
        {
            isUploading = true;
            mContext = LocationService.radiomapContext;

		    Vertex currentVertex = Map2DOffline.SelectedOfflineVertex;
			SymbolicLocation currentSymLoc = currentVertex.SymbolicLocations.FirstOrDefault();
			//1) upload NEW symbolic location 
			if (currentSymLoc == null)
            {
                mContext.AddRelatedObject(currentVertex, "SymbolicLocations", tmpSymLoc);
                currentVertex.SymbolicLocations.Add(tmpSymLoc);
			}
			//2) or UPDATE existing
			else
			{
                //copy updated values 
                currentSymLoc.title = tmpSymLoc.title;
                currentSymLoc.description = tmpSymLoc.description;
                currentSymLoc.url = tmpSymLoc.url;
                currentSymLoc.is_entrance = tmpSymLoc.is_entrance;    
                
                mContext.UpdateObject(currentSymLoc);				
			}
            try
            {
                mContext.BeginSaveChanges(OnChangesSaved, mContext);
                
                //uploadProgressBar.Visibility = System.Windows.Visibility.Visible;
                uploadProgressIndicator.IsVisible = isUploading;             
                
            }
            catch (Exception ex)
            {
                isUploading = false;
                uploadProgressIndicator.IsVisible = isUploading;
                                
                MessageBox.Show(string.Format("The changes could not be saved.\n"
                    + "The following error occurred: {0}", ex.Message));
            }
		}
        void saveButton_Click(object sender, EventArgs e)
        {            							
			//tmpSymLoc is used to pass data to UploadSymbolicLocationTask
            //Whether the operation is CREATE or UPDATE is determined in UploadSymbolicLocationTask
            SymbolicLocation tmpSymLoc = new SymbolicLocation();
            tmpSymLoc.title = titleTextBox.Text;
            tmpSymLoc.description =  descriptionTextBox.Text;
            tmpSymLoc.url = urlTextBox.Text;
			tmpSymLoc.is_entrance = isEntranceCheckBox.IsChecked;
            int selectedInfoType = infoTypeListBox.SelectedIndex;
            tmpSymLoc.info_type = selectedInfoType < 0 ? 0 : selectedInfoType;

            UploadSymbolicLocationTask(tmpSymLoc);             
        }
 private void initializeInputBoxes()
 {            
     SymbolicLocation tmpSymLoc = Map2DOffline.SelectedOfflineVertex.SymbolicLocations.FirstOrDefault();
     if (tmpSymLoc == null)
     {
         tmpSymLoc = new SymbolicLocation();
     }
     else //populate the input boxes
     {
         //Binding is not worth the hassle, but goes like this:
         //Binding titleBinding = new Binding("title");
         //titleBinding.Source = tmpSymLoc;
         //titleTextBox.SetBinding(TextBlock.TextProperty, titleBinding);
         titleTextBox.Text = tmpSymLoc.title ?? "";
         descriptionTextBox.Text = tmpSymLoc.description ?? "";
         urlTextBox.Text = tmpSymLoc.url ?? "";
         isEntranceCheckBox.IsChecked = tmpSymLoc.is_entrance;
     }    
 }