Exemplo n.º 1
0
        /// <summary>
        /// Gets the search result for hotel search information
        /// </summary>
        /// <param name="hsi"></param>
        /// <returns></returns>
        public Model.Entities.Hotel.SearchResult SearchForHotels(Model.Entities.Hotel.SearchInfo hsi)
        {
            HappyTrip.Model.Entities.Hotel.SearchResult hsr = new HappyTrip.Model.Entities.Hotel.SearchResult();

            Database db = GetDatabaseConnection();


            using (IDataReader reader = db.ExecuteReader("GetHotels", hsi.DesitinationCity.CityId, hsi.CheckInDate, hsi.CheckOutDate, hsi.NoOfPeople, hsi.NoOfRooms))
            {
                try
                {
                    while (reader.Read())
                    {
                        HappyTrip.Model.Entities.Hotel.Hotel h = new HappyTrip.Model.Entities.Hotel.Hotel();
                        h.HotelId     = Convert.ToInt64(reader["HotelId"]);
                        h.HotelName   = reader["HotelName"].ToString();
                        h.PhotoUrl    = reader["PhotoUrl"].ToString();
                        h.StarRanking = Convert.ToInt32(reader["StarRanking"]);

                        hsr.AddHotel(h);
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            return(hsr);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the search result for hotel search information
        /// </summary>
        /// <param name="hsi"></param>
        /// <returns></returns>
        public Model.Entities.Hotel.SearchResult SearchForHotels(Model.Entities.Hotel.SearchInfo hsi)
        {
            HappyTrip.Model.Entities.Hotel.SearchResult hsr = new HappyTrip.Model.Entities.Hotel.SearchResult();

            try
            {
                using (IDbConnection db = GetConnection())
                {
                    using (IDataReader reader = ExecuteStoredProcedureResults(db, "GetHotels",
                                                                              new SqlParameter()
                    {
                        ParameterName = "@xxx", DbType = DbType.String, Value = hsi.DesitinationCity.CityId
                    },
                                                                              new SqlParameter()
                    {
                        ParameterName = "@xxx", DbType = DbType.String, Value = hsi.CheckInDate
                    },
                                                                              new SqlParameter()
                    {
                        ParameterName = "@xxx", DbType = DbType.String, Value = hsi.CheckOutDate
                    },
                                                                              new SqlParameter()
                    {
                        ParameterName = "@xxx", DbType = DbType.String, Value = hsi.NoOfPeople
                    },
                                                                              new SqlParameter()
                    {
                        ParameterName = "@xxx", DbType = DbType.String, Value = hsi.NoOfRooms
                    })
                           )
                    {
                        while (reader.Read())
                        {
                            HappyTrip.Model.Entities.Hotel.Hotel h = new HappyTrip.Model.Entities.Hotel.Hotel();
                            h.HotelId     = Convert.ToInt64(reader["HotelId"]);
                            h.HotelName   = reader["HotelName"].ToString();
                            h.PhotoUrl    = reader["PhotoUrl"].ToString();
                            h.StarRanking = Convert.ToInt32(reader["StarRanking"]);

                            hsr.AddHotel(h);
                        }
                    }
                }
            }
            catch (Common.ConnectToDatabaseException ex)
            {
                throw new HotelDAOException("Unable to search for hotels", ex);
            }
            catch (Exception ex)
            {
                throw new HotelDAOException("Unable to search for hotels", ex);
            }

            return(hsr);
        }
        /// <summary>
        /// Hotel Search Manager (Business Layer). Gets the hotels from our database
        /// </summary>
        /// <param name="hsQuery"></param>
        /// <returns></returns>
        public HappyTrip.Model.Entities.Hotel.SearchResult SearchForHotels(HappyTrip.Model.Entities.Hotel.SearchInfo hsQuery)
        {
            // Added a comment
            HappyTrip.Model.Entities.Hotel.SearchResult hsr = null;

            HappyTrip.DataAccessLayer.Hotel.IHotelSearchDAO hotelDao = HappyTrip.DataAccessLayer.Hotel.HotelDAOFactory.GetInstance().Create();

            hsr = hotelDao.SearchForHotels(hsQuery);

            return(hsr);
        }