Beispiel #1
0
        public RPN_API_Json.Storage GetStorageFromId(int id)
        {
            using (WebClient wb = new WebClient())
            {
                NameValueCollection defaultPost = GetLoginPost();
                defaultPost.Set("type", "storage");
                defaultPost.Set("action", "getfromid");
                defaultPost.Set("id", id.ToString());

                byte[] response         = wb.UploadValues(BaseURL + "storage.php", "POST", defaultPost);
                string responseInString = Encoding.UTF8.GetString(response);

                // Convert to C# Class typed object
                RPN_API_Json.StorageJSON data = JsonConvert.DeserializeObject <RPN_API_Json.StorageJSON>(responseInString);

                return(data.Data[0]);
            }
        }
Beispiel #2
0
        public List <RPN_API_Json.Storage> GetStorages()
        {
            using (WebClient wb = new WebClient())
            {
                NameValueCollection defaultPost = GetLoginPost();
                defaultPost.Set("type", "storage");
                defaultPost.Set("action", "get");

                byte[] response = wb.UploadValues(BaseURL + "storage.php", "POST", defaultPost);
                if (response == null) // skip list creation
                {
                    return(null);
                }
                string responseInString = Encoding.UTF8.GetString(response);

                // Convert to C# Class typed object
                RPN_API_Json.StorageJSON data = JsonConvert.DeserializeObject <RPN_API_Json.StorageJSON>(responseInString);

                return(data.Data.ToList());
            }
        }