コード例 #1
0
 public IActionResult socialMedia()
 {
     rootObject = GetAllSocial();
     if (_repository.getSocialData())
     {
         bool areNewRecordsAdded = _repository.SaveSocial(rootObject);
     }
     return(View(rootObject));
 }
コード例 #2
0
        static public List <RootObject3> DownloadInfo()
        {
            List <RootObject3> rootObjects = new List <RootObject3>();
            List <string>      ServerGUIDs = FileHandler.ServerGUID();

            foreach (var GUID in ServerGUIDs)
            {
                WebClient            playerJSON  = new WebClient();
                string               json        = playerJSON.DownloadString("http://battlelog.battlefield.com/bf4/servers/show/pc/" + GUID + "/?json=1");
                JavaScriptSerializer ser         = new JavaScriptSerializer();
                RootObject3          rootobejct3 = ser.Deserialize <RootObject3>(json);
                rootObjects.Add(rootobejct3);
            }

            return(rootObjects);
        }
コード例 #3
0
        public RootObject3 GetAllSocial()
        {
            string CompaniesApi_End_Point = BASE_URL + "?API_KEY=qZEyjY0nTO9R8suzDCwQs06eVpyfFOkY7UVacerl";
            string companyList            = string.Empty;

            httpClient.BaseAddress = new Uri(CompaniesApi_End_Point);
            HttpResponseMessage response = httpClient.GetAsync(CompaniesApi_End_Point).GetAwaiter().GetResult();

            if (response.IsSuccessStatusCode)
            {
                companyList = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
            }
            if (!string.IsNullOrEmpty(companyList))
            {
                rootObject = JsonConvert.DeserializeObject <RootObject3>(companyList);
            }
            return(rootObject);
        }