public TrainStation(double Lat, double Long, string tsName) : base(Lat, Long, tsName) { this.city = null; this.wheelchairFriendly = true; this.taxiRank = true; this.carPark = true; }
public void addLocation(Location venue, City toCity) { //look up the City database and add the location to the city /* if (venue is School) { toCity.schools.Add((School)venue); ((School)venue).city = toCity; } else if (venue is Hospital) { toCity.hospitals.Add((Hospital)venue); ((Hospital)venue).city = toCity; } else { toCity.venues.Add(venue); } * */ }
public bool addCityToDb(City c) { City inc = new City(); try { inc = db.cities.Add(c); } catch (Exception e) { Exception j = e; return false; //do something } if (inc is City) { db.SaveChanges(); return true; } return false; }
public City deleteLocation(Location venue, City fromCity) { return null; }
public bool updateCityInDb(City c) { db.Entry(c).State = EntityState.Modified; try { db.SaveChanges(); return true; } catch (Exception e) { // do something return false; } }
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 } }