Exemple #1
0
        public void OnGet()
        {
            string       line;
            string       path = Path.Combine(_environment.ContentRootPath, "CrashDetails.txt");
            StreamReader file = new System.IO.StreamReader(path);

            while ((line = file.ReadLine()) != null)
            {
                string[]            data = line.Split(',');
                TrafficCrashVehicle fs   = new TrafficCrashVehicle();
                fs.CrashUnitId = data[0];
                fs.RdNo        = data[1];
                fs.UnitType    = data[2];
                fs.VehicleId   = data[3];
                fs.Make        = data[4];
                fs.Model       = data[5];

                TrafficCrashVehicle.Add(fs);
            }
            file.Close();
        }
        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;
            }
        }