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 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); }