コード例 #1
0
ファイル: Index.cshtml.cs プロジェクト: Ajinkya2010/IS7024
        public void OnPost()
        {
            using (var WebClient = new WebClient())
            {
                string jsonString_police = GetJsonData("https://data.cincinnati-oh.gov/resource/ksej-uzjq.json");
                policeCrimes = PoliceCrime.FromJson(jsonString_police);
                policeCrimes = policeCrimes.Where(x => x.Neighborhood.ToLower().Equals(Search.ToLower())).ToArray();
                ViewData["PoliceCrime"] = policeCrimes;

                string jsonString_drug = GetJsonData("https://data.cincinnati-oh.gov/resource/7mtn-nnb5.json");
                drugCrimes = DrugCrime.FromJson(jsonString_drug);
                drugCrimes = drugCrimes.Where(x => x.CommunityCouncilNeighborhood.ToLower().Equals(Search.ToLower())).ToArray();
                ViewData["DrugCrimes"] = drugCrimes;
            }
            HashSet<string> neighborhoods = new HashSet<string>();
            foreach (PoliceCrime permit in policeCrimeAuto)
            {
                neighborhoods.Add(permit.Neighborhood);
            }
            foreach (DrugCrime permit in drugCrimeAuto)
            {
                neighborhoods.Add(permit.CommunityCouncilNeighborhood);
            }
            ViewData["Neighborhoods"] = neighborhoods;
            SearchCompleted = true;

        }
コード例 #2
0
ファイル: Index.cshtml.cs プロジェクト: Ajinkya2010/IS7024
        public IndexModel()
        {
            using (var webClient = new WebClient())
            {


                String policeCrimeJsonString = GetJsonData("https://data.cincinnati-oh.gov/resource/ksej-uzjq.json");
                policeCrimeAuto = PoliceCrime.FromJson(policeCrimeJsonString);
                String drugCrimeJsonString = GetJsonData("https://data.cincinnati-oh.gov/resource/7mtn-nnb5.json");
                drugCrimeAuto = DrugCrime.FromJson(drugCrimeJsonString);





            }
        }
コード例 #3
0
        public ActionResult <IEnumerable <Neighbourhood> > GetNeighbourhood(string id)
        {
            List <Neighbourhood> Neighbourhood = new List <Neighbourhood>();
            string location = id;

            using (var webClient = new WebClient())
            {
                String jsonString_police = webClient.DownloadString("https://data.cincinnati-oh.gov/resource/ksej-uzjq.json");
                policeCrimes = PoliceCrime.FromJson(jsonString_police);
                policeCrimes = policeCrimes.Where(x => x.Neighborhood.ToUpper().Equals(location.ToUpper())).ToArray();
                String jsonString_drug = webClient.DownloadString("https://data.cincinnati-oh.gov/resource/7mtn-nnb5.json");
                drugCrimes = DrugCrime.FromJson(jsonString_drug);
                drugCrimes = drugCrimes.Where(x => x.CommunityCouncilNeighborhood.ToUpper().Equals(location.ToUpper())).ToArray();
            }
            foreach (PoliceCrime police in policeCrimes)
            {
                Neighbourhood nh = new Neighbourhood();
                nh.Address      = police.AddressX;
                nh.Neighborhood = police.Neighborhood;
                nh.Latitude     = police.LatitudeX;
                nh.Longitude    = police.LongitudeX;
                nh.CrimeType    = "Any Crime";
                nh.Weapon       = police.Weapons;
                Neighbourhood.Add(nh);
            }
            foreach (DrugCrime drug in drugCrimes)
            {
                Neighbourhood nh = new Neighbourhood();
                nh.Address      = drug.AddressX;
                nh.Neighborhood = drug.CommunityCouncilNeighborhood;
                nh.Latitude     = drug.LatitudeX;
                nh.Longitude    = drug.LongitudeX;
                nh.CrimeType    = "Drug Crime";
                nh.Weapon       = "None";
                Neighbourhood.Add(nh);
            }
            return(Neighbourhood);
        }