/// <summary>
        /// Look for all the free rooms during a period of a hotel to know the number of free room, free space and the occupation rate
        /// </summary>
        public static HotelAvailability GetAvailability(int idHotel, DateTime arrival, DateTime departure)
        {
            HotelAvailability hotelAvailability = new HotelAvailability();
            int     availablePlace = 0;
            decimal minPrice       = decimal.MaxValue;

            List <Room> rooms = RoomDB.GetRoomsWithNoReservationByHotel(idHotel, arrival, departure);

            foreach (Room room in rooms)
            {
                availablePlace += room.Type;

                if (room.Price < minPrice)
                {
                    minPrice = room.Price;
                }
            }

            double totalRoom = GetCapacity(idHotel).TotalNumberRoom;

            double occupancyRate = 1.0 - (rooms.Count() / totalRoom);

            hotelAvailability.NumberOfAvailableRoom         = rooms.Count();
            hotelAvailability.NumberOfAvailablePerson       = availablePlace;
            hotelAvailability.OcucupancyRate                = occupancyRate;
            hotelAvailability.HasAvailableRoomWithTv        = rooms.Any(room => room.HasTV == true);
            hotelAvailability.HasAvailableRoomWithHairDryer = rooms.Any(room => room.HasHairDryer == true);
            hotelAvailability.MinPrice = minPrice;

            return(hotelAvailability);
        }
Example #2
0
        /// <summary>
        /// Return a list of Room who has no reservation during a defined period and in relation with a hotel
        /// </summary>
        public static List <Room> GetRoomsWithNoReservationByHotel(int idHotel, DateTime arrival, DateTime departure)
        {
            List <Room> rooms = RoomDB.GetRoomsWithNoReservationByHotel(idHotel, arrival, departure);

            return(rooms);
        }