Ejemplo n.º 1
0
        private void lostFocus(object sender, EventArgs e)
        {
            Entry snt = (Entry)sender;

            Console.WriteLine("Unfocusing: " + snt.AutomationId);
            int selectedIndex = InfoStore.getAirshowIndex(InfoStore.Selected);


            if (validate(snt))
            {
                JSONToPatch += "\"" + snt.AutomationId + "\":" + "\"" + snt.Text.Trim() + "\",";
                if (badEntries.Contains(snt.AutomationId))
                {
                    badEntries.Remove(snt.AutomationId);
                }
                readyToSend = true;
            }
            else if (!readyToSend)
            {
            }
            else
            {
                if (!badEntries.Contains(snt.AutomationId))
                {
                    badEntries.Add(snt.AutomationId);
                }
            }
        }
Ejemplo n.º 2
0
        public static List <string> getFoodNames()
        {
            List <string> Foods = new List <string>();

            foreach (Food foo in Database.Airshows[InfoStore.getAirshowIndex(InfoStore.Selected)].Foods)
            {
                Foods.Add(foo.Name);
            }
            return(Foods);
        }
Ejemplo n.º 3
0
        public static List <string> getPerformerNames()
        {
            List <string> Names = new List <string>();

            foreach (Performer perf in Database.Airshows[InfoStore.getAirshowIndex(InfoStore.Selected)].Performers)
            {
                Names.Add(perf.Name);
            }
            return(Names);
        }
Ejemplo n.º 4
0
        public static List <string> getDirectionNames()
        {
            List <string>    Names      = new List <string>();
            List <Direction> directions = Database.Airshows[InfoStore.getAirshowIndex(InfoStore.Selected)].Directions ?? new List <Direction>();

            foreach (Direction dir in directions)
            {
                Names.Add(dir.Name);
            }
            return(Names);
        }
Ejemplo n.º 5
0
        public static List <string> getStaticNames()
        {
            List <string> names = new List <string>();

            foreach (Static stat in Database.Airshows[InfoStore.getAirshowIndex(InfoStore.Selected)].Statics)
            {
                if (stat.Name != null)
                {
                    names.Add(stat.Name);
                }
            }
            return(names.Count >= 1 ? names : null);
        }
Ejemplo n.º 6
0
        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");
            }
        }
Ejemplo n.º 7
0
        public static Performer getPerformerByName(string performerName)
        {
            int intIndex = 0;

            foreach (Performer perf in Database.Airshows[InfoStore.getAirshowIndex(InfoStore.Selected)].Performers)
            {
                if (perf.Name == performerName)
                {
                    performerIndex = intIndex;
                    return(perf);
                }
                intIndex++;
            }
            return(new Performer("", "", "Preparing", "", Convert.ToString(Database.Airshows[InfoStore.getAirshowIndex(InfoStore.Selected)].Performers.Count + 1)));
        }
Ejemplo n.º 8
0
        public static Direction getDirectionByName(string directionName)
        {
            int intIndex = 0;
            List <Direction> directions = Database.Airshows[(InfoStore.getAirshowIndex(InfoStore.Selected))].Directions ?? new List <Direction>();

            foreach (Direction dir in directions)
            {
                if (dir.Name == directionName)
                {
                    return(dir);
                }
                intIndex++;
            }
            return(new Direction(false, "", "", 0, 0));
        }
Ejemplo n.º 9
0
        public static Food getFoodByName(string foodName)
        {
            int intIndex = 0;

            foreach (Food foo in Database.Airshows[InfoStore.getAirshowIndex(InfoStore.Selected)].Foods)
            {
                if (foo.Name == foodName)
                {
                    foodIndex = intIndex;
                    return(foo);
                }
                intIndex++;
            }
            return(new Food("", ""));
        }
Ejemplo n.º 10
0
        public static Static getStaticByName(string staticName)
        {
            int intIndex = 0;

            foreach (Static stat in Database.Airshows[InfoStore.getAirshowIndex(InfoStore.Selected)].Statics)
            {
                if (stat.Name == staticName)
                {
                    staticIndex = intIndex;
                    return(stat);
                }
                intIndex++;
            }
            return(new Static("", "", ""));
        }
Ejemplo n.º 11
0
        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());
            }
        }
Ejemplo n.º 12
0
 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");
     }
 }
Ejemplo n.º 13
0
        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());
            }
        }
Ejemplo n.º 14
0
        //This works because I created a list of entries^^. Everytime a new entry is made I add it to the list. Now we can Foreach them easily
        //I interate through the list and find all the entries that have the same autoID as the sender button
        //Then I create a string for every entry that matches and add the string to the JSONToPatch string
        //So the save buttons send a patch for every child of the specific performer that has the same index as their autoID... not best practice but it works
        private void sendPatch(object sender, EventArgs e)
        {
            Button btnSender = (Button)sender;

            string strIndex = btnSender.AutomationId;

            string JSONToPatch = "";

            foreach (View v in entries)
            {
                if (v.GetType() == typeof(Entry))
                {
                    Entry ent = v as Entry;
                    if (ent.AutomationId.Split('.')[1] == strIndex)
                    {
                        JSONToPatch += "\"" + ent.AutomationId.Split('.')[0] + "\":\"" + ent.Text.Trim() + "\",";
                    }
                }
                else if (v.GetType() == typeof(Editor))
                {
                    Editor edt = v as Editor;
                    if (edt.AutomationId.Split('.')[1] == strIndex)
                    {
                        JSONToPatch += "\"" + edt.AutomationId.Split('.')[0] + "\":\"" + edt.Text.Trim() + "\",";
                    }
                }
                else if (v.GetType() == typeof(Picker))
                {
                    Picker pck = v as Picker;
                    if (pck.AutomationId.Split('.')[1] == strIndex)
                    {
                        JSONToPatch += "\"" + pck.AutomationId.Split('.')[0] + "\":\"" + pck.SelectedItem.ToString() + "\",";
                    }
                }
            }
            JSONToPatch = "{" + JSONToPatch.Substring(0, JSONToPatch.LastIndexOf(',')) + "}";

            try
            {
                User   currentUser = InfoStore.CurrentUser;
                string target      = "https://airshowapp-d193b.firebaseio.com/Airshows/" + InfoStore.getAirshowIndex(InfoStore.Selected) + "/Performers/" + btnSender.AutomationId + ".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);
                JObject response    = JObject.Parse(rawResponse);

                Console.Write("Response is: " + rawResponse);
            }
            catch (Exception E)
            {
                Console.WriteLine(E.ToString());
            }
        }
Ejemplo n.º 15
0
        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());
                }
            }
        }
Ejemplo n.º 16
0
        private void sendPatch()
        {
            try
            {
                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", JSONToPatch);
                JObject response    = JObject.Parse(rawResponse);

                Console.Write("Response is: " + rawResponse);
                readyToSend = false;
            }
            catch (Exception E)
            {
                Console.WriteLine(E.ToString());
            }
        }
Ejemplo n.º 17
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());
                }
            }
        }
Ejemplo n.º 18
0
        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 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());
            }
        }