private void addMarketsFiletoDB()
        {
            List<Market> mkList = csvr.getCSVFileDataMarkets();
            MarketDAL mkDAL = new MarketDAL();

            // Get all the Markets already in the dB and compare to this list
            // Add any in this list that aren't in the dB
            // Update any in this list that are already in the dB

            List<Market> dbmkList = mkDAL.getAllMarketsFromDb();

            bool result = false, notIndB = true;

            // stick it in the dB
            foreach (Market mk in mkList)
            {
                if (dbmkList.Count() > 0)
                {
                    foreach (Market dbmk in dbmkList)
                    {
                        if (dbmk.lname.Equals(mk.lname))
                        {
                            notIndB = false;
                            break;
                        }
                    }
                }
                if (notIndB)
                {
                    // Add to the dB

                    // we could bother to check the result
                    result = mkDAL.addMarketToDb(mk);
                }
                else
                {
                    // Update the record in the dB (assuming structure the same)
                    // I think we change every field in the dbm that could have changed
                    // and then call mDAL.updateMarketInDb(dbm)
                }
                notIndB = true;
            }
        }
        public ActionResult Index()
        {
            List<City> cList = new List<City>();
            CitiesDAL cDal = new CitiesDAL();
            List<Museum> mList = new List<Museum>();
            MuseumDAL mDal = new MuseumDAL();
            List<Park> pList = new List<Park>();
            ParkDAL pDal = new ParkDAL();
            List<Market> mkList = new List<Market>();
            MarketDAL mkDal = new MarketDAL();

            cList = cDal.getAllCitiesFromDb(true);
            mList = mDal.getAllMuseumsFromDb(true);
            pList = pDal.getAllParksFromDb(true);
            mkList = mkDal.getAllMarketsFromDb(true);

            //System.Web.Script.Serialization.JavaScriptSerializer oSerializer =
            //new System.Web.Script.Serialization.JavaScriptSerializer();
            //string sJSON = oSerializer.Serialize(cList);
            var serializerSettings = new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.Objects };
            string cjson = JsonConvert.SerializeObject(cList, Formatting.Indented, serializerSettings);
            string mjson = JsonConvert.SerializeObject(mList, Formatting.Indented, serializerSettings);
            string pjson = JsonConvert.SerializeObject(pList, Formatting.Indented, serializerSettings);
            string mkjson = JsonConvert.SerializeObject(mkList, Formatting.Indented, serializerSettings);
            //string sjson2 = JsonConvert.ToString(cList[0]);
            ViewData["Cities"] = cjson;
            ViewData["Museums"] = mjson;
            ViewData["Parks"] = pjson;
            ViewData["Markets"] = mkjson;

            return View(cList);
        }
        public BuildCities()
        {
            // list of all museums in dB
            // list of all other venues to follow
            List<Museum> ms = new List<Museum>();
            List<Park> ps = new List<Park>();
            List<Market> mks = new List<Market>();
            // temporary list of cities
            List<City> cs = new List<City>();
            MuseumDAL mDal = new MuseumDAL();
            ParkDAL pDal = new ParkDAL();
            MarketDAL mkDal = new MarketDAL();

            ms = mDal.getAllMuseumsFromDb();

            if (ms.Count() > 0)
            {

                foreach (Museum m in ms)
                {
                    bool notFound = true;
                    foreach (City c in cs)
                    {
                        if (m.cityStr.Equals(c.lname))
                        {
                            // Add museum to list of this city's museums
                            c.museums.Add(m);
                            notFound = false;
                            break;
                        }
                    }
                    if (notFound)
                    {
                        City addCity = new City();
                        addCity.lname = m.cityStr;
                        addCity.latitude = m.latitude;
                        addCity.longitude = m.longitude;
                        // Add museum to list of this city's museums
                        //addCity.museums = new List<Museum>();
                        addCity.museums.Add(m);
                        cs.Add(addCity);
                    }
                }
            }

            // Do this again for each other venue
            ps = pDal.getAllParksFromDb();

            if (ps.Count() > 0)
            {
                foreach (Park p in ps)
                {
                    bool notFound = true;
                    foreach (City c in cs)
                    {
                        if (p.cityStr.Equals(c.lname))
                        {
                            // Add museum to list of this city's museums
                            c.parks.Add(p);
                            notFound = false;
                            break;
                        }
                    }
                    if (notFound)
                    {
                        City addCity = new City();
                        addCity.lname = p.cityStr;
                        addCity.latitude = p.latitude;
                        addCity.longitude = p.longitude;
                        // Add museum to list of this city's museums
                        //addCity.museums = new List<Museum>();
                        addCity.parks.Add(p);
                        cs.Add(addCity);
                    }
                }
            }

            // Do this again for each other venue
            mks = mkDal.getAllMarketsFromDb();
            if (mks.Count() > 0)
            {
                foreach (Market ma in mks)
                {
                    bool notFound = true;
                    foreach (City c in cs)
                    {
                        if (ma.cityStr.Equals(c.lname))
                        {
                            // Add museum to list of this city's museums
                            c.markets.Add(ma);
                            notFound = false;
                            break;
                        }
                    }
                    if (notFound)
                    {
                        City addCity = new City();
                        addCity.lname = ma.cityStr;
                        addCity.latitude = ma.latitude;
                        addCity.longitude = ma.longitude;
                        // Add museum to list of this city's museums
                        //addCity.museums = new List<Museum>();
                        addCity.markets.Add(ma);
                        cs.Add(addCity);
                    }
                }
            }

            // We have created our temporary list of cities, now add them to the dB
            CitiesDAL cDal = new CitiesDAL();
            List<City> lCitiesInDB = new List<City>();
            lCitiesInDB = cDal.getAllCitiesFromDb();
            bool result = false, notIndB = true;

            if (cs.Count() > 0)
            {
                foreach (City c in cs)
                {
                    if (lCitiesInDB.Count() > 0)
                    {
                        foreach (City dcb in lCitiesInDB)
                        {
                            if (dcb.lname.Equals(c.lname))
                            {
                                notIndB = false;
                                break;
                            }
                        }
                    }
                    if (notIndB)
                    {
                        result = cDal.addCityToDb(c);
                        if (result.Equals(false))
                        {
                            //do something
                        }
                    }
                    notIndB = true;
                    // see if it has an id now
                }
            }
        }