Пример #1
0
        private void performSave()
        {
            string JSONToPatch = "";

            JSONToPatch += "\"" + txtName.AutomationId + "\":\"" + txtName.Text.Trim() + "\",";
            JSONToPatch += "\"" + txtDesc.AutomationId + "\":\"" + txtDesc.Text.Trim() + "\",";

            JSONToPatch = "{" + JSONToPatch.Substring(0, JSONToPatch.LastIndexOf(','));

            JSONToPatch += ",\" Last Updated By \":\"" + current.localId + "\"}";

            if (index > InfoStore.getFoodNames().Count)
            {
                try
                {
                    User   currentUser = InfoStore.CurrentUser;
                    string target      = "https://airshowapp-d193b.firebaseio.com/Airshows/" + InfoStore.getAirshowIndex(InfoStore.Selected) + "/Foods/" + index.ToString() + ".json?auth=" + currentUser.token;

                    ServicePointManager.ServerCertificateValidationCallback += (send, certificate, chain, sslPolicyErrors) => { return(true); };

                    WebClient client = new WebClient();
                    client.Headers[HttpRequestHeader.ContentType] = "application/json";
                    string rawResponse = client.UploadString(new Uri(target), "PUT", JSONToPatch);

                    Console.Write("Response is: " + rawResponse);

                    InfoStore.getDatabase();
                    LoadPage(new pgEditFoods());
                }
                catch (Exception E)
                {
                    Console.WriteLine(E.ToString());
                }
            }
            else
            {
                try
                {
                    // JSONToPatch = String.Concat(" ", JSONToPatch);
                    User   currentUser = InfoStore.CurrentUser;
                    string target      = "https://airshowapp-d193b.firebaseio.com/Airshows/" + InfoStore.getAirshowIndex(InfoStore.Selected) + "/Foods/" + index.ToString() + ".json?auth=" + currentUser.token;

                    ServicePointManager.ServerCertificateValidationCallback += (send, certificate, chain, sslPolicyErrors) => { return(true); };

                    WebClient client = new WebClient();
                    client.Headers[HttpRequestHeader.ContentType] = "application/json";
                    string rawResponse = client.UploadString(new Uri(target), "PUT", JSONToPatch);

                    Console.Write("Response is: " + rawResponse);

                    InfoStore.getDatabase();
                    LoadPage(new pgEditFoods());
                }
                catch (Exception E)
                {
                    Console.WriteLine(E.ToString());
                }
            }
        }
Пример #2
0
 public pgEditFoods()
 {
     InitializeComponent();
     btnBack = (Button)myStackLayout.Children[2];
     foreach (string name in InfoStore.getFoodNames())
     {
         pckFoods.Items.Add(name);
     }
     pckFoods.Items.Add("Add New Food");
     if (Device.RuntimePlatform == Device.Android)
     {
         backButton.IsVisible = false;
     }
 }
Пример #3
0
 private void deleteFood(object sender, EventArgs e)
 {
     InfoStore.getDatabase();
     if (Database.Airshows[InfoStore.getAirshowIndex(InfoStore.Selected)].Foods.Count > 1)
     {
         performDelete();
     }
     else if (!InfoStore.getFoodNames().Contains(txtName.Text.Trim()))
     {
         LoadPage(new pgEditFoods());
         App.Current.MainPage.DisplayAlert("Delete Food Error", "Error deleting food set. Please make sure the \"Name\" entry has not been changed", "OK");
     }
     else
     {
         LoadPage(new pgEditFoods());
         App.Current.MainPage.DisplayAlert("Delete Food Error", "There must be at least food set. Please add another before attempting to delete one", "OK");
     }
 }