Esempio n. 1
0
        private static void AddPicture(string picName, int id, string Url)
        {
            CheckForConnection();
            NamesValues stuffToInput = new NamesValues {
                ID = id, url = Url, name = picName
            };

            InsertData("Names/" + stuffToInput.ID, stuffToInput);
        }
Esempio n. 2
0
        public static void AddPicture(string picName)
        {
            CheckForConnection();
            int newID = GetNumberOfNames() + 1;

            NamesValues stuffToInput = new NamesValues {
                ID = newID, name = picName
            };

            InsertData("Names/" + stuffToInput.ID, stuffToInput);
            SetNumberOfNames(newID);
        }
Esempio n. 3
0
        public static void InsertPictureIntoPicturesWithGarbage(string _name, string _url)
        {
            CheckForConnection();
            int newNum = GetNumberOfPicturesWithGarbage() + 1;


            NamesValues newThing = new NamesValues {
                name = _name, url = _url, ID = newNum
            };


            InsertData("NamesWithGarbage/" + newThing.ID, newThing);
            SetNumberOfPicturesWithGarbage(newThing.ID);
        }
Esempio n. 4
0
        public static NamesValues[] GetAllPictureNames()
        {
            CheckForConnection();
            var    response = GetData("Names");
            object json     = JsonConvert.DeserializeObject(response.Body);

            if (json == null)
            {
                return(null);
            }

            List <NamesValues> values = new List <NamesValues>();

            foreach (JToken item in ((JToken)(json)).Children())
            {
                NamesValues newPatchNote = null;
                try
                {
                    newPatchNote = item.ToObject <NamesValues>();
                }
                catch
                {
                    try
                    {
                        var x     = item.Children()[0];
                        var token = (JToken)x;
                        newPatchNote = token.ToObject <NamesValues>();
                    }
                    catch
                    {
                        var x = (JProperty)item;
                        var y = x.Value <JProperty>();

                        var children = y.Children();
                        newPatchNote = new NamesValues();
                        foreach (var child in children.First().Children())
                        {
                            var prop = (JProperty)child;
                            if (prop.Name == "name")
                            {
                                newPatchNote.name = prop.Value.ToString();
                            }
                            else if (prop.Name == "url")
                            {
                                newPatchNote.url = prop.Value.ToString();
                            }
                            else if (prop.Name == "ID")
                            {
                                newPatchNote.ID = Convert.ToInt32(prop.Value.ToString());
                            }
                        }
                    }
                }
                values.Add(newPatchNote);
            }

            for (int x = values.Count - 1; x >= 0; x--)
            {
                if (values[x] == null)
                {
                    values.RemoveAt(x);
                }
            }

            return(values.ToArray());
        }