public long AddChargingStationData(string postalCode, int chargingStationCount, int portCount) { long result = 0; using (CIDEntities dbContext = new CIDEntities()) { try { charging_station_data entity = new charging_station_data() { postal_code = postalCode, station_count = chargingStationCount, port_count = portCount, date = DateTime.Now }; dbContext.charging_station_data.Add(entity); if (dbContext.SaveChanges() > 0) { result = entity.id; } } catch (Exception ex) { result = 0; string.Format("Unable to add charging station data: {0}.", ex); } } return(result); }
public app_config GetAppConfig(long id) { using (CIDEntities dbContext = new CIDEntities()) { app_config entity = dbContext.app_config.FirstOrDefault(row => row.id == id); return(entity); } }
public location GetLocationByPostalCode(string postalCode) { location entity = new location(); using (CIDEntities dbContext = new CIDEntities()) { try { entity = dbContext.locations.FirstOrDefault(row => row.postal_code == postalCode); } catch (Exception) { string.Format("unable to retrieve location by postal code: {0}", postalCode); } } return(entity); }
public metropolitan_area GetMetropolitanAreaById(Int32 id) { metropolitan_area entity = new metropolitan_area(); using (CIDEntities dbContext = new CIDEntities()) { try { entity = dbContext.metropolitan_area.FirstOrDefault(row => row.id == id); } catch (Exception) { string.Format("unable to retrieve metropolitan area by id: {0}", id); } } return(entity); }
public state GetStateByStateCode(string code) { state entity = new state(); using (CIDEntities dbContext = new CIDEntities()) { try { entity = dbContext.states.FirstOrDefault(row => row.state_cd == code); } catch (Exception) { string.Format("unable to retrieve state by code: {0}", code); } } return(entity); }
public List <app_config> GetAppConfigs() { var list = new List <app_config>(); using (CIDEntities dbContext = new CIDEntities()) { try { list = dbContext.app_config.ToList(); } catch { string.Format("unable to retrieve app_config records"); } } return(list); }
public List <metropolitan_area> GetAllMetropolitanAreas() { var list = new List <metropolitan_area>(); using (CIDEntities dbContext = new CIDEntities()) { try { var query = from m in dbContext.metropolitan_area select m; list = query.ToList(); } catch (Exception) { string.Format("unable to retrieve metropolitan areas"); } } return(list); }
public bool UpdateAppConfig(string name, string value) { bool result = true; using (CIDEntities dbContext = new CIDEntities()) { try { app_config entity = dbContext.app_config.FirstOrDefault(row => row.name == name); entity.value = value; dbContext.SaveChanges(); } catch (Exception) { string.Format("unable to retrieve app_config by name: {0}", name); } } return(result); }
public List <location> GetLocationsByMetropolitanAreaId(Int32 metroAreaId) { var list = new List <location>(); using (CIDEntities dbContext = new CIDEntities()) { try { var query = from l in dbContext.locations where l.metropolitan_area_id == metroAreaId select l; list = query.ToList(); } catch (Exception) { string.Format("unable to retrieve locations by metropolitan area id: {0}", metroAreaId); } } return(list); }
public List <charging_station_data> GetChargingStationDataByPostalCode(string postal_code) { var list = new List <charging_station_data>(); using (CIDEntities dbContext = new CIDEntities()) { try { var query = from c in dbContext.charging_station_data where c.postal_code == postal_code select c; list = query.ToList(); } catch (Exception) { string.Format("unable to retrieve charging station data by postal code: {0}", postal_code); } } return(list); }
public List <location> GetLocationsByState(string state) { var list = new List <location>(); using (CIDEntities dbContext = new CIDEntities()) { try { var query = from l in dbContext.locations where l.state == state select l; list = query.ToList(); } catch (Exception) { string.Format("unable to retrieve locations by state name: {0}", state); } } return(list); }