예제 #1
0
        public async Task <string> getAPI2()
        {
            App.Database.reset();
            var client = new System.Net.Http.HttpClient();

            client.BaseAddress = new Uri("http://thursdayhomework.azurewebsites.net/");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));


            var response = await client.GetAsync("API/GetItemList/2");

            var listJson = response.Content.ReadAsStringAsync().Result;


            dynamic results = JsonConvert.DeserializeObject(listJson);

            var data = string.Empty;


            for (var i = 0; i < results.data.Count; i++)
            {
                data = results.data[i].Name;
                apiData api = new apiData();
                api.Error_Code = results.error_code;
                api.Msg        = results.msg;
                api.Name       = results.data[i].Name;
                api.Attribute  = results.data[i].Attribute;
                api.Value      = results.data[i].Value;

                await App.Database.InsertAPI(api);
            }

            return(data);
        }
        public Task <int> InsertAPI(apiData data)
        {
            if (data.ApiID != 0) //Updating Item
            {
                return(database.UpdateAsync(data));
            }

            return(database.InsertAsync(data));
        }
예제 #3
0
 private void ProcessPlayer(string getResult)
 {
     ImmuData = JsonUtility.FromJson <apiData>(getResult);
 }
 public Task <int> deleteAPI(apiData data)
 {
     return(database.DeleteAsync(data));
 }