public List<Reservation> GetUpcomingUserRes(string uid) { string Query = "SELECT date, startTime, endTime, roomName FROM reservations WHERE userID='" + uid + "' AND date>'" + DateTime.Now.ToString("yyyy-MM-dd") +"' ORDER BY date;"; MySqlCommand getReservationsByUser = new MySqlCommand(Query, this.sqlConn); MySqlDataReader myReader = getReservationsByUser.ExecuteReader(); List<Reservation> reservations = new List<Reservation>(); try { while (myReader.Read()) { string translateDate = myReader.GetDateTime(0).ToString("yyyy-MM-dd"); Reservation res = new Reservation(translateDate, myReader.GetString(1), myReader.GetString(2), myReader.GetString(3), uid, false); reservations.Add(res); } myReader.Close(); } catch (Exception e) { Exception myExcp = new Exception("Could not verify user. Error: " + e.Message, e); throw (myExcp); } return reservations; }
public List<Reservation> GetReservationsByRoom(string date, string rm) { string Query; if(rm == "") Query = "SELECT startTime, endTime, roomName, userID FROM reservations WHERE date='" + date + "';"; else Query = "SELECT startTime, endTime, roomName, userID FROM reservations WHERE roomName='" + rm + "' AND date='" + date + "';"; MySqlCommand getReservations = new MySqlCommand(Query, this.sqlConn); MySqlDataReader myReader = getReservations.ExecuteReader(); List<Reservation> reservations = new List<Reservation>(); try { while (myReader.Read()) { Reservation res = new Reservation(date, myReader.GetString(0), myReader.GetString(1), myReader.GetString(2), myReader.GetString(3), false); reservations.Add(res); } myReader.Close(); } catch (Exception e) { Exception myExcp = new Exception("Could not verify user. Error: " + e.Message, e); throw (myExcp); } return reservations; }