Esempio n. 1
0
        public void Post([FromBody] CityWeatherStation value)
        {
            CityWeatherStation station = value;

            DataProvider.AddCityWeatherStation(station.cityID, station.zipCode, station.country);
            return;
        }
Esempio n. 2
0
        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 + "'");
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        public CityWeatherStation Get(string cityId)
        {
            CityWeatherStation station = DataProvider.GetCityWeatherStation(cityId);

            return(station);
        }