Exemplo n.º 1
0
        public void DemographicsScript()
        {
            List <int> allZipCodes      = zipCsv.Replace(" ", String.Empty).Split(',').ToList().ConvertAll <int>(x => Convert.ToInt32(x));
            List <int> selectedZipCodes = allZipCodes.GetRange(592, 1);

            List <DemographicsModel> results = DemographicsQuery.GetDemographics(selectedZipCodes, false, 0);

            DemographicsData.UpdateDatabase(results);
        }
Exemplo n.º 2
0
        public static void GetDemographics()
        {
            // Try to read zips from app.config
            string zipCsv = ConfigurationManager.AppSettings["zipCodes"];

            List <int> allZipCodes     = zipCsv.Replace(" ", String.Empty).Split(',').ToList().ConvertAll <int>(x => Convert.ToInt32(x));
            List <int> missingZipCodes = new List <int>(); //allZipCodes.GetRange(592, 1);

            using (SportsDataContext db = new SportsDataContext())
            {
                missingZipCodes = allZipCodes.Except(db.Demographic_DbSet.Select(z => z.Zip).ToList()).ToList();
            }

            if (missingZipCodes.Count == 0)
            {
                Console.WriteLine("All zip codes have been retrieved and stored in the database. To update existing zip code data, delete it from the database and re-run");
                Console.WriteLine("Zip codes in the list of zip codes to retrieve:");
                Console.WriteLine(allZipCodes);
            }

            List <DemographicsModel> results = DemographicsQuery.GetDemographics(missingZipCodes, false, 0);

            DemographicsData.UpdateDatabase(results);
        }
Exemplo n.º 3
0
        public void DemographicsTest()
        {
            List <int> zipCodes = new List <int> {
                98103, 98052, 98007
            };

            List <DemographicsModel> results = DemographicsQuery.GetDemographics(zipCodes);

            Assert.AreEqual(3, results.Count);

            DemographicsModel fremont = results.Single(x => x.Zip == 98103);

            Assert.AreEqual(49044, fremont.MedianIncome);
            Assert.AreEqual(73, fremont.MedianIncomeRank);

            Assert.AreEqual(43.9, fremont.OwnerOccupiedHomesPercent);
            Assert.AreEqual(5, fremont.OwnerOccupiedHomesRank);

            Assert.AreEqual(36.5, fremont.MarriedPercent);
            Assert.AreEqual(2, fremont.MarriedRank);

            Assert.AreEqual("Seattle", fremont.City);
            Assert.AreEqual("WA", fremont.State);
        }