public JsonResult OnGet()
        {
            List<Owner> cafeOwners = new List<Owner>();

            string CafeJsonString = GetData("https://data.cityofchicago.org/resource/mqmh-p6ud.json");
            Cafe[] allCafes = Cafe.FromJson(CafeJsonString);
            
            string OwnerJsonString = GetData("https://data.cityofchicago.org/resource/ezma-pppn.json");
            Owner[] allOwners = Owner.FromJson(OwnerJsonString);
                                  
            IDictionary<string, Cafe> cafes = new Dictionary<string, Cafe>();

            foreach (Cafe cafe in allCafes)
            {
                cafes.Add(cafe.PermitNumber, cafe);
            }

            foreach (Owner owner in allOwners)
            {
                foreach (var cafe in cafes)
                {
                    //Compare Account Number from two JSON and select only ones which have common account number
                    if (cafe.Value.AccountNumber == owner.AccountNumber)
                    {
                        cafeOwners.Add(owner);
                    }
                }
            }

            return new JsonResult(cafeOwners);
        }
Exemplo n.º 2
0
        public void OnGet()
        {
            List <Owner> cafeOwners = new List <Owner>();

            string CafeJsonString = GetData("https://data.cityofchicago.org/resource/mqmh-p6ud.json");

            Cafe[] allCafes = Cafe.FromJson(CafeJsonString);
            ViewData["allCafes"] = allCafes;

            string OwnerJsonString = GetData("https://data.cityofchicago.org/resource/ezma-pppn.json");

            Owner[] allOwners = Owner.FromJson(OwnerJsonString);
            ViewData["allOwners"] = allOwners;

            IDictionary <string, Cafe> cafes = new Dictionary <string, Cafe>();

            foreach (Cafe cafe in allCafes)
            {
                cafes.Add(cafe.PermitNumber, cafe);
            }

            foreach (Owner owner in allOwners)
            {
                foreach (var cafe in cafes)
                {
                    if (cafe.Value.AccountNumber == owner.AccountNumber)
                    {
                        cafeOwners.Add(owner);
                    }
                }
            }
            ViewData["cafeOwners"] = cafeOwners;
        }
        public void OnGet()
        {
            List <Owner> cafeOwners = new List <Owner>();

            string CafeJsonString = GetData("https://data.cityofchicago.org/resource/mqmh-p6ud.json");

            Cafe[] allCafes = Cafe.FromJson(CafeJsonString);
            ViewData["allCafes"] = allCafes;

            string OwnerJsonString = GetData("https://data.cityofchicago.org/resource/ezma-pppn.json");

            Owner[] allOwners = Owner.FromJson(OwnerJsonString);
            ViewData["allOwners"] = allOwners;



            IDictionary <string, Cafe> cafes = new Dictionary <string, Cafe>();

            foreach (Cafe cafe in allCafes)
            {
                cafes.Add(cafe.PermitNumber, cafe);
            }

            foreach (Owner owner in allOwners)
            {
                foreach (var cafe in cafes)
                {
                    //Compare Account Number from two JSON and select only ones which have common account number
                    if (cafe.Value.AccountNumber == owner.AccountNumber)
                    {
                        cafeOwners.Add(owner);
                    }

                    if (owner.IsNameNull(owner.OwnerFirstName + owner.OwnerMiddleInitial + owner.OwnerLastName))
                    {
                        ViewData["ownerNames"] = "No Information Available";
                    }
                }
            }

            ViewData["cafeOwners"] = cafeOwners;
        }