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()); } } }
private void deleteStatics(object sender, EventArgs e) { InfoStore.getDatabase(); if (Database.Airshows[InfoStore.getAirshowIndex(InfoStore.Selected)].Statics.Count > 1) { performDelete(); } else { App.Current.MainPage = new pgEditStatics(); App.Current.MainPage.DisplayAlert("Delete Error", "There must be at least one static display stored. Please add another before attempting to delete one.", "OK"); } }
private void btnSave_Clicked(object sender, EventArgs e) { if (badEntries.Count > 0) { DisplayAlert("Save Error", "Ensure all entries are valid", "OK"); } else if (JSONToPatch != null && JSONToPatch.Length > 0) { JSONToPatch = "{" + JSONToPatch.Substring(0, JSONToPatch.LastIndexOf(',')); JSONToPatch += ",\" Last Updated By \":\"" + current.localId + "\"" + "}"; sendPatch(); JSONToPatch = ""; readyToSend = false; InfoStore.getDatabase(); } }
private void performDelete() { string toWrite = ""; Static statToDelete = new Static("", "", ""); foreach (Static stat in Database.Airshows[InfoStore.getAirshowIndex(InfoStore.Selected)].Statics) { if (stat.Name == txtName.Text.Trim()) { statToDelete = stat; } } try { Database.Airshows[InfoStore.getAirshowIndex(InfoStore.Selected)].Statics.Remove(statToDelete); toWrite = JsonConvert.SerializeObject(Database.Airshows[InfoStore.getAirshowIndex(InfoStore.Selected)].Statics); Console.WriteLine(toWrite); } catch (Exception E) { App.Current.MainPage.DisplayAlert("Delete Error", "There was an error deleting this entry. Make sure that no fields were changed and try again", "OK"); Console.WriteLine(E.ToString()); LoadPage(new pgEditStatics()); } try { User currentUser = InfoStore.CurrentUser; string target = "https://airshowapp-d193b.firebaseio.com/Airshows/" + InfoStore.getAirshowIndex(InfoStore.Selected) + "/Statics/.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", toWrite); Console.Write("Response is: " + rawResponse); InfoStore.getDatabase(); LoadPage(new pgEditStatics()); } catch (Exception E) { App.Current.MainPage.DisplayAlert("Delete Error", "There was an error deleting this entry. Make sure that no fields were changed and try again", "OK"); Console.WriteLine(E.ToString()); } }
private void performDelete() { string toWrite = "{\"Performers\":"; Performer perfToDelete = new Performer("", "", "", "", "1"); foreach (Performer perf in Database.Airshows[aSIndex].Performers) { if (perf.Name.Trim() == txtName.Text.Trim()) { perfToDelete = perf; } } try { Database.Airshows[aSIndex].Performers.Remove(perfToDelete); toWrite += JsonConvert.SerializeObject(Database.Airshows[aSIndex].Performers); Console.WriteLine(toWrite); } catch (Exception E) { Console.WriteLine(E.ToString()); } try { toWrite += "}"; User currentUser = InfoStore.CurrentUser; string target = "https://airshowapp-d193b.firebaseio.com/Airshows/" + InfoStore.getAirshowIndex(InfoStore.Selected) + "/.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), "PATCH", toWrite); JObject response = JObject.Parse(rawResponse); Console.Write("Response is: " + rawResponse); InfoStore.getDatabase(); LoadPage(new pgEditPerformers()); } catch (Exception E) { Console.WriteLine(E.ToString()); } }
private void btnDelete_Pressed(object sender, EventArgs e) { InfoStore.getDatabase(); if (Database.Airshows[InfoStore.getAirshowIndex(InfoStore.Selected + 1)].Directions.Count > 1) { performDelete(); } else if (!InfoStore.getDirectionNames().Contains(txtName.Text.Trim())) { LoadPage(new pgEditDirections()); App.Current.MainPage.DisplayAlert("Delete Directions Error", "Error deleting direction set. Please make sure the \"Name\" entry has not been changed", "OK"); } else { LoadPage(new pgEditDirections()); App.Current.MainPage.DisplayAlert("Delete Directions Error", "There must be at least one direction set. Please add another before attempting to delete one", "OK"); } }
private void performDelete() { string toWrite = ""; Direction dirToDelete = new Direction(false, "", "", 0, 0); foreach (Direction dir in Database.Airshows[InfoStore.getAirshowIndex(InfoStore.Selected)].Directions) { if (dir.Name == txtName.Text.Trim()) { dirToDelete = dir; } } try { Database.Airshows[InfoStore.getAirshowIndex(InfoStore.Selected)].Directions.Remove(dirToDelete); toWrite = JsonConvert.SerializeObject(Database.Airshows[InfoStore.getAirshowIndex(InfoStore.Selected)].Directions); } catch (Exception E) { Console.WriteLine(E.ToString()); } try { User currentUser = InfoStore.CurrentUser; string target = "https://airshowapp-d193b.firebaseio.com/Airshows/" + InfoStore.getAirshowIndex(InfoStore.Selected) + "/Directions/.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", toWrite); Console.Write("Response is: " + rawResponse); InfoStore.getDatabase(); LoadPage(new pgEditDirections()); } catch (Exception E) { Console.WriteLine(E.ToString()); } }
private void btnLogin_Clicked(object sender, EventArgs e) { NavigationPage navPage = new NavigationPage(this); IList <View> children = loginStackLayout.Children; if (txtUsername.Text.Trim() != "" && txtPass.Text.Trim() != "") { if (Login(txtUsername.Text, txtPass.Text)) { InfoStore.getDatabase(); App.Current.MainPage = new pgSelectOrCreate(); } else { DisplayAlert("Login Invalid", "Input correct credentials", "OK"); txtPass.Text = ""; txtUsername.Text = ""; } } }
private void performSave() { string JSONToPatch = "{"; //string JSONToPatch = JsonConvert.SerializeObject(new Static(txtName.Text.Trim(), txtDesc.Text.Trim(), txtImage.Text.Trim())); foreach (View v in stkLayout.Children) { if (v.GetType() == typeof(Entry)) { Entry txtBox = v as Entry; JSONToPatch += "\"" + txtBox.AutomationId + "\":\"" + txtBox.Text.Trim() + "\","; } else if (v.GetType() == typeof(Editor)) { Editor txtBox = v as Editor; JSONToPatch += "\"" + txtBox.AutomationId + "\":\"" + txtBox.Text.Trim() + "\","; } } JSONToPatch += "\" Last Updated By \":\"" + current.localId + "\"}"; if (index > InfoStore.getStaticNames().Count) { try { User currentUser = InfoStore.CurrentUser; string target = "https://airshowapp-d193b.firebaseio.com/Airshows/" + InfoStore.getAirshowIndex(InfoStore.Selected) + "/Statics/" + 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 pgEditStatics()); } 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) + "/Statics/" + 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); JObject response = JObject.Parse(rawResponse); Console.Write("Response is: " + rawResponse); InfoStore.getDatabase(); LoadPage(new pgEditStatics()); } catch (Exception E) { App.Current.MainPage.DisplayAlert("Save Error", "There was an error saving this entry. Make sure that all fields are valid and try again", "OK"); Console.WriteLine(E.ToString()); } } }
private void performSave() { string JSONToPatch = ""; JSONToPatch += "\"" + txtName.AutomationId + "\":\"" + txtName.Text.Trim() + "\","; JSONToPatch += "\"" + pckFull.AutomationId + "\":" + pckFull.SelectedItem.ToString().ToLower() + ","; JSONToPatch += "\"" + txtXCoord.AutomationId + "\":" + Convert.ToDouble(txtXCoord.Text.Trim()) + ","; JSONToPatch += "\"" + txtYCoord.AutomationId + "\":" + Convert.ToDouble(txtYCoord.Text.Trim()) + ","; JSONToPatch += "\"" + pckType.AutomationId + "\":\"" + pckType.SelectedItem.ToString() + "\","; JSONToPatch += "\" Last Updated By \":\"" + current.localId + "\","; JSONToPatch = "{" + JSONToPatch.Substring(0, JSONToPatch.LastIndexOf(',')) + "}"; if (index > InfoStore.getDirectionNames().Count) { try { User currentUser = InfoStore.CurrentUser; string target = "https://airshowapp-d193b.firebaseio.com/Airshows/" + InfoStore.getAirshowIndex(InfoStore.Selected) + "/Directions/" + index.ToString() + ".json?auth=" + currentUser.token; ServicePointManager.ServerCertificateValidationCallback += (send, certificate, chain, sslPolicyErrors) => { return(true); }; Console.WriteLine("Patch note: " + JSONToPatch); WebClient client = new WebClient(); client.Headers[HttpRequestHeader.ContentType] = "application/json"; string rawResponse = client.UploadString(new Uri(target), "PUT", JSONToPatch); InfoStore.getDatabase(); LoadPage(new pgEditDirections()); } catch (Exception E) { Console.WriteLine(E.ToString()); App.Current.MainPage.DisplayAlert("Save Error", "There was an error saving this entry. Please try again", "OK"); LoadPage(new pgEditDirections()); } } else { try { // JSONToPatch = String.Concat(" ", JSONToPatch); User currentUser = InfoStore.CurrentUser; string target = "https://airshowapp-d193b.firebaseio.com/Airshows/" + InfoStore.getAirshowIndex(InfoStore.Selected) + "/Directions/" + index.ToString() + ".json?auth=" + currentUser.token; ServicePointManager.ServerCertificateValidationCallback += (send, certificate, chain, sslPolicyErrors) => { return(true); }; WebClient client = new WebClient(); client.Headers[HttpRequestHeader.ContentType] = "application/json"; Console.WriteLine("Patched: " + JSONToPatch); string rawResponse = client.UploadString(new Uri(target), "PATCH", JSONToPatch); Console.Write("Response is: " + rawResponse); InfoStore.getDatabase(); LoadPage(new pgEditDirections()); } catch (Exception E) { Console.WriteLine(E.ToString()); LoadPage(new pgEditDirections()); } } }
private void performSave() { try { string JSONToPatch = "{"; OrderPerformers(); //JSONToPatch = JsonConvert.SerializeObject(Database.Airshows[aSIndex].Performers); IList <Entry> entries = new List <Entry>(); foreach (View v in stkLayout.Children) { if (v.GetType() == typeof(Entry)) { string textToAdd = ""; Entry txtBox = v as Entry; if (txtBox.AutomationId == "Image" && txtBox.Text.Trim() == "") { textToAdd = "https://i.imgur.com/mXv4hUL.png"; } else { textToAdd = txtBox.Text; } JSONToPatch += "\"" + txtBox.AutomationId + "\":\"" + textToAdd + "\","; } else if (v.GetType() == typeof(Editor)) { Editor edit = v as Editor; JSONToPatch += "\"" + edit.AutomationId + "\":\"" + edit.Text.Trim() + "\","; } else if (v.GetType() == typeof(Picker)) { Picker pick = v as Picker; JSONToPatch += "\"" + pick.AutomationId + "\":\"" + pick.SelectedItem.ToString() + "\","; } } JSONToPatch = JSONToPatch.Substring(0, JSONToPatch.LastIndexOf(',')); JSONToPatch += ",\" Last Updated By \":\"" + current.localId + "\"}"; Console.WriteLine(JSONToPatch); User currentUser = InfoStore.CurrentUser; string target = "https://airshowapp-d193b.firebaseio.com/Airshows/" + aSIndex.ToString() + "/Performers/" + index + "/.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), "PATCH", JSONToPatch); Console.Write("Response is: " + rawResponse); } catch (Exception E) { Console.Write(E.ToString()); } InfoStore.getDatabase(); LoadPage(new pgEditPerformers()); }