public static List <PressureByDay> GetPressure() { ISession session = SessionManager.GetSession(); List <PressureByDay> pressure = new List <PressureByDay>(); if (session == null) { return(null); } var PressureData = session.Execute("select * from \"pressure_by_day\""); foreach (var hd in PressureData) { PressureByDay h = new PressureByDay(); h.cityID = hd["city_id"] != null ? hd["city_id"].ToString() : string.Empty; h.date = hd["date"] != null?DateTime.Parse(hd["date"].ToString()) : DateTime.Parse(string.Empty); h.eventTime = hd["event_time"] != null?DateTime.Parse(hd["event_time"].ToString()) : DateTime.Parse(string.Empty); h.pressure = hd["pressure"] != null ? hd["pressure"].ToString() : string.Empty; pressure.Add(h); } return(pressure); }
public static PressureByDay GetPressureByEventTime(string city_id, string date, string eventTime) { ISession session = SessionManager.GetSession(); PressureByDay p = new PressureByDay(); if (session == null) { return(null); } Row PressureData = session.Execute("select * from \"pressure_by_day\" where \"city_id\"='" + city_id + "' and \"date\"='" + date + "' and \"event_time\"='" + eventTime + "'").FirstOrDefault(); if (PressureData != null) { p.cityID = PressureData["city_id"] != null ? PressureData["city_id"].ToString() : string.Empty; p.date = PressureData["date"] != null?DateTime.Parse(PressureData["date"].ToString()) : DateTime.Parse(string.Empty); p.eventTime = PressureData["event_time"] != null?DateTime.Parse(PressureData["event_time"].ToString()) : DateTime.Parse(string.Empty); p.pressure = PressureData["pressure"] != null ? PressureData["pressure"].ToString() : string.Empty; } return(p); }