예제 #1
0
        // GET: Parking
        public async Task <ActionResult> Index()
        {
            //Initialize
            IParking repos = DataFactory.ParkingRepository();

            //Setting target Url
            string     targetURI = ConfigurationManager.AppSettings["ParkingInfoURL"].ToString();
            HttpClient client    = new HttpClient();

            client.MaxResponseContentBufferSize = Int32.MaxValue;
            //Get Parking Json Format (not completed json)
            var response = await client.GetStringAsync(targetURI);

            JObject o          = (JObject)JsonConvert.DeserializeObject(response);
            string  parkString = o.SelectToken("result").SelectToken("records").ToString();

            //Deserialize
            var collection = JsonConvert.DeserializeObject <IEnumerable <ParkingDeserialize> >(parkString);

            //Add Parking Info
            repos.AddOutParking(collection);

            return(View());
        }