public void Post([FromBody] CityWeatherStation value) { CityWeatherStation station = value; DataProvider.AddCityWeatherStation(station.cityID, station.zipCode, station.country); return; }
public static void DeleteCityWeatherStation(string city_id) { ISession session = SessionManager.GetSession(); CityWeatherStation CityWeatherStation = new CityWeatherStation(); if (session == null) { return; } RowSet CityWeatherStationData = session.Execute("delete from \"city_weather_station\" where \"city_id\" = '" + city_id + "'"); }
public static CityWeatherStation GetCityWeatherStation(string city_id) { ISession session = SessionManager.GetSession(); CityWeatherStation ws = new CityWeatherStation(); if (session == null) { return(null); } //promenice se city id sa parametrom Row CityWeatherStationData = session.Execute("select * from \"city_weather_station\" where \"city_id\"= '" + city_id + "'").FirstOrDefault(); if (CityWeatherStationData != null) { ws.cityID = CityWeatherStationData["city_id"] != null ? CityWeatherStationData["city_id"].ToString() : string.Empty; ws.zipCode = CityWeatherStationData["zip_code"] != null ? CityWeatherStationData["zip_code"].ToString() : string.Empty; ws.country = CityWeatherStationData["country"] != null ? CityWeatherStationData["country"].ToString() : string.Empty; } return(ws); }
public static List <CityWeatherStation> GetCityWeatherStations() { ISession session = SessionManager.GetSession(); List <CityWeatherStation> stations = new List <CityWeatherStation>(); if (session == null) { return(null); } var CityWeatherStationsData = session.Execute("select * from \"city_weather_station\""); foreach (var CityWeatherStationData in CityWeatherStationsData) { CityWeatherStation CityWeatherStation = new CityWeatherStation(); CityWeatherStation.cityID = CityWeatherStationData["city_id"] != null ? CityWeatherStationData["city_id"].ToString() : string.Empty; CityWeatherStation.zipCode = CityWeatherStationData["zip_code"] != null ? CityWeatherStationData["zip_code"].ToString() : string.Empty; CityWeatherStation.country = CityWeatherStationData["country"] != null ? CityWeatherStationData["country"].ToString() : string.Empty; stations.Add(CityWeatherStation); } return(stations); }
public CityWeatherStation Get(string cityId) { CityWeatherStation station = DataProvider.GetCityWeatherStation(cityId); return(station); }