//if the text boxes are not empty save the cafe to the database.
        private void btnsave_Click(object sender, RoutedEventArgs e)
        {
            if (txtName.Text.Trim().Length != 0 && txtTradeName.Text.Trim().Length != 0 && txtStreetAddress.Text.Trim().Length != 0 && txtPhoneNumber.Text.Trim().Length != 0 && txtLongitude.Text.Trim().Length != 0 && txtLatitude.Text.Trim().Length != 0)
            {
                //create the new cafe.
                //I have structured the Location it like this sinice this is how it is stored in the database.
                Cafe newCafe = new Cafe(txtName.Text, txtTradeName.Text, txtStreetAddress.Text, txtPhoneNumber.Text, "Location(" + txtLatitude.Text + ", " + txtLongitude.Text + ")");
                viewModel.AddNewCafe(newCafe); //add it the the List.
                flyoutPopup.IsOpen = false;

                // **Make sure to Open the app bar so you can access it again**
                bottomAppBar.Visibility = Visibility.Visible;
            }
        }
예제 #2
0
        //add the new cafe to the database
        public async void SaveCafe(Cafe cafe)
        {
            try
            {
                // Encode the components of the link so that they can be attached to the URL
                string encodedLink = await cafe.GetUrlEncodedLinkAsString();

                // Now attempt to add the link to the database
                string              url      = "http://sidewalkcafes.azurewebsites.net/php/addcafe.php?" + encodedLink; //PHP script to add any new cafes to the database
                HttpClient          client   = new HttpClient();
                HttpResponseMessage response = await client.GetAsync(url);

                response.EnsureSuccessStatusCode();
            }
            catch
            {
                //If the update fails the user should be made aware so they can try again.
            }
            //Save to the file after updating te database
            SaveCafesToFile();
        }
예제 #3
0
        /// <summary>
        /// Add a new cafe to the view model and use the web service to update the database in the cloud.
        /// The local cache file is also updated.
        /// </summary>
        /// <param name="cafe">The cafe to be added</param>

        public void AddNewCafe(Cafe cafe)
        {
            AddCafeToModel(cafe);
            SaveCafe(cafe);
        }
예제 #4
0
        /// <summary>
        /// Add a cafe to the view model.
        /// </summary>
        /// <param name="cafe">The cafe to be added</param>

        public void AddCafeToModel(Cafe cafe)
        {
            Cafes.Add(cafe);
        }
        //if the text boxes are not empty save the cafe to the database.
        private void btnsave_Click(object sender, RoutedEventArgs e)
        {
            if (txtName.Text.Trim().Length != 0 && txtTradeName.Text.Trim().Length != 0 && txtStreetAddress.Text.Trim().Length != 0 && txtPhoneNumber.Text.Trim().Length != 0 && txtLongitude.Text.Trim().Length != 0 && txtLatitude.Text.Trim().Length != 0)
            {
                //create the new cafe.
                //I have structured the Location it like this sinice this is how it is stored in the database.
                Cafe newCafe = new Cafe(txtName.Text, txtTradeName.Text, txtStreetAddress.Text, txtPhoneNumber.Text, "Location(" + txtLatitude.Text + ", " + txtLongitude.Text + ")");
                viewModel.AddNewCafe(newCafe); //add it the the List.
                flyoutPopup.IsOpen = false;

                // **Make sure to Open the app bar so you can access it again**
                bottomAppBar.Visibility = Visibility.Visible;
            }
        }
예제 #6
0
 //add the new cafe to the database
 public async void SaveCafe(Cafe cafe)
 {
     try
     {
         // Encode the components of the link so that they can be attached to the URL
         string encodedLink = await cafe.GetUrlEncodedLinkAsString();
         // Now attempt to add the link to the database
         string url = "http://sidewalkcafes.azurewebsites.net/php/addcafe.php?" + encodedLink; //PHP script to add any new cafes to the database
         HttpClient client = new HttpClient();
         HttpResponseMessage response = await client.GetAsync(url);
         response.EnsureSuccessStatusCode();
     }
     catch
     {
         //If the update fails the user should be made aware so they can try again.
        
     }
     //Save to the file after updating te database
     SaveCafesToFile();
 }
예제 #7
0
        /// <summary>
        /// Add a new cafe to the view model and use the web service to update the database in the cloud.
        /// The local cache file is also updated.
        /// </summary>
        /// <param name="cafe">The cafe to be added</param>

        public void AddNewCafe(Cafe cafe)
        {
            AddCafeToModel(cafe);
            SaveCafe(cafe);
        }
예제 #8
0
        /// <summary>
        /// Add a cafe to the view model.
        /// </summary>
        /// <param name="cafe">The cafe to be added</param>

        public void AddCafeToModel(Cafe cafe)
        {
            Cafes.Add(cafe);
        }