Beispiel #1
0
        public static ResortAvailability GetResortAvailability(DateTime startDate, DateTime endDate)
        {
            SetUpHttpClient();

            // TODO: Look at following location headers instead of hardcoding URLs?
            string cookieRequestsQueryString = string.Format("?CIM={0}&CID={1}&CIY={2}&COM={3}&COD={4}&COY={5}&checkInDate={1}-{6}-{2}&checkOutDate={4}-{7}-{5}&AD=2&CH=0&RMS=1&promoCode=&submit=Check+Availability",
                                                             startDate.Month,
                                                             startDate.ToString("dd"),
                                                             startDate.Year,
                                                             endDate.Month,
                                                             endDate.ToString("dd"),
                                                             endDate.Year,
                                                             startDate.ToString("MMM"),
                                                             endDate.ToString("MMM"));

            string initialCookieRequestUrl = REQUESTS_ROOT_URL + "default.asp" + cookieRequestsQueryString;
            string initialAspCookie        = GetAspCookie(UTM_COOKIES, initialCookieRequestUrl);

            string mainCookieRequestUrl = REQUESTS_ROOT_URL + "asp/home.asp" + cookieRequestsQueryString;
            string mainAspCookie        = GetAspCookie(UTM_COOKIES + "; " + initialAspCookie, mainCookieRequestUrl);

            string fullCookie = UTM_COOKIES + "; " + mainAspCookie;

            HotelAvailability hotelAvailability = GetHotelAvailability(startDate, endDate, fullCookie);

            hotelAvailability.TrimDateRange(startDate, endDate);

            return(new ResortAvailability(ResortName.SILVER_CREEK, new Dictionary <HotelName, HotelAvailability> {
                { HotelName.SILVER_CREEK, hotelAvailability }
            }));
        }
Beispiel #2
0
        public static async Task <HotelAvailability> GetAvailabilityForHotel(HotelName hotelName, DateTime startDate, DateTime endDate)
        {
            Dictionary <string, Object> roomsData = ReadRoomDataFromFile(hotelName);

            HotelAvailability hotelAvailability = new HotelAvailability(hotelName);
            List <DateTime>   requestDates      = CalculateRequestDates(startDate, endDate);

            foreach (DateTime requestDate in requestDates)
            {
                await AddAvailabilityAroundDate(hotelAvailability, requestDate, roomsData);
            }
            hotelAvailability.TrimDateRange(startDate, endDate);

            Console.WriteLine("\nEarliest available date for " + hotelName.Name + ": " + hotelAvailability.GetEarliestKnownDate().ToLongDateString());
            Console.WriteLine("Latest available date for " + hotelName.Name + ": " + hotelAvailability.GetLatestKnownDate().ToLongDateString() + "\n");
            Console.WriteLine("Total number of rooms gathered for " + hotelName.Name + ": " + hotelAvailability.RoomAvailabilities.Count);
            return(hotelAvailability);
        }