public void getAllMuseumsFromDbTest()
        {
            MuseumDAL target = new MuseumDAL();
            bool forVisual = false;

            List<Museum> actual;

               // IEnumerable<Museum> actual;
            actual = target.getAllMuseumsFromDb(forVisual);

            //** Assert List of Museums is returned **//
            Assert.IsInstanceOfType(actual, typeof(List<Museum>));
        }
        public void addMuseumToDbTest()
        {
            MuseumDAL target = new MuseumDAL();

            double lat = 40.7669569450;
            double lng = -73.937655144;
            string theName = "Test Museum",theUrl = "www.testmuseum.com", add1 = "Bronx", add2 = null, theZip = "008", phone = "007007";
            string cityStr = "New York";

            Museum mTest = new Museum(lat, lng, theName, phone, theUrl, add1, add2, theZip, cityStr);

            bool expected = true;
            bool actual;
            actual = target.addMuseumToDb(mTest);

            // ** Check it was added **/
            Assert.AreEqual(expected, actual);
        }
Пример #3
0
        private void addMusuemsFiletoDB()
        {
            List<Museum> mList = csvr.getCSVFileDataMuseums();
            MuseumDAL mDAL = new MuseumDAL();

            // Get all the Parks 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<Museum> dbmList = mDAL.getAllMuseumsFromDb();

            bool result = false, notIndB = true;

            // stick it in the dB
            foreach (Museum m in mList)
            {
                if (dbmList.Count > 0)
                {
                    foreach (Museum dbm in dbmList)
                    {
                        if (dbm.lname.Equals(m.lname))
                        {
                            notIndB = false;
                            break;
                        }
                    }
                }
                if (notIndB)
                {
                    // Add to the dB

                    // we could bother to check the result
                    result = mDAL.addMuseumToDb(m);
                }
                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.updateMuseumInDb(dbm)
                }
                notIndB = true;
            }
        }
 public void MuseumDALConstructorTest()
 {
     MuseumDAL target = new MuseumDAL();
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
        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);
        }
        // ** Query Museum DB **
        public ActionResult QueryMuseumDB()
        {
            string searchFor = "history";

            MuseumDAL mDAL = new MuseumDAL();

            List<Museum> musList = mDAL.findMuseumFromUserInput();        //two different search methods
            //List<Museum> musList = mDAL.findMuseumFromdB(searchFor);

            return View(musList);
        }
Пример #7
0
        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>();
            // temporary list of cities
            List<City> cs = new List<City>();
            MuseumDAL mDal = new MuseumDAL();
            ParkDAL pDal = new ParkDAL();

            ms = mDal.getAllMuseumsFromDb();

            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();
            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 = 79.0;
                    addCity.longitude = 79.0;
                    // Add museum to list of this city's museums
                    //addCity.museums = new List<Museum>();
                    addCity.parks.Add(p);
                    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;
            foreach (City c in cs)
            {
                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
            }
        }