Beispiel #1
0
        public JsonResult OnGet()
        {
            string city = HttpContext.Request.Query["city"];

            string url = "https://data.cityofchicago.org/resource/u6pd-qa9d.json?";


            url = url + "city=" + city;

            string crashDetails = getData(url);

            TrafficCrashPeople[] array = TrafficCrashPeople.FromJson(crashDetails);

            return(new JsonResult(array));
        }
        public void OnPost()

        {
            using (var webClient = new WebClient())
            {
                string vehicleJson = webClient.DownloadString("https://data.cityofchicago.org/resource/68nd-jvt3.json");
                TrafficCrashVehicle[] allVehicles = TrafficCrashVehicle.FromJson(vehicleJson);

                string peopleJson = webClient.DownloadString("https://data.cityofchicago.org/resource/u6pd-qa9d.json");
                TrafficCrashPeople[] allPeople = TrafficCrashPeople.FromJson(peopleJson);

                allVehicles             = allVehicles.Where(x => x.RdNo.ToUpper().Equals(Search.ToUpper())).ToArray();
                ViewData["allVehicles"] = allVehicles;

                allPeople             = allPeople.Where(x => x.RdNo.ToUpper().Equals(Search.ToUpper())).ToArray();
                ViewData["allPeople"] = allPeople;


                SearchCompleted = true;
            }
        }