public List<RoomAndType> GetListOfAllRooms() { List<RoomAndType> listOfAllRooms = null; using (DataTable table = DBHelper.ExecuteSelectCommand("sp_GetListOfAllRooms", CommandType.StoredProcedure)) { if (table.Rows.Count > 0) { listOfAllRooms = new List<RoomAndType>(); foreach (DataRow row in table.Rows) { RoomAndType roomAndType = new RoomAndType(); roomAndType.RoomID = Convert.ToInt32(row["RoomID"]); roomAndType.RoomNo = row["RoomNo"].ToString(); roomAndType.Name = row["Name"].ToString(); roomAndType.Picture = row["Picture"].ToString(); roomAndType.MaxCapacity = Convert.ToInt32(row["MaxCapacity"]); roomAndType.Rate = Convert.ToDouble(row["RatePerNight"]); listOfAllRooms.Add(roomAndType); } } } return listOfAllRooms; }
public RoomAndType GetAvailableRoomDetails(int roomID) { RoomAndType roomAndType = null; SqlParameter[] paramaters = new SqlParameter[] { new SqlParameter("@roomID", roomID) }; using (DataTable table = DBHelper.ExecuteParamerizedSelectCommand("sp_GetSpecificAvailableRoom", CommandType.StoredProcedure, paramaters)) { if (table.Rows.Count == 1) { DataRow row = table.Rows[0]; roomAndType = new RoomAndType(); roomAndType.RoomID = Convert.ToInt32(row["RoomID"]); roomAndType.RoomNo = row["RoomNo"].ToString(); roomAndType.Name = row["Name"].ToString(); roomAndType.MaxCapacity = Convert.ToInt32(row["MaxCapacity"]); roomAndType.Rate = Convert.ToDouble(row["RatePerNight"]); } } return roomAndType; }