Esempio n. 1
0
        public ActionResult SearchHotel(FormCollection collection)
        {
            HotelSearchDto searchCriteria = new HotelSearchDto();

            searchCriteria.Address    = collection["add"];
            searchCriteria.Latitude   = double.Parse(collection["lat"]);
            searchCriteria.Longitude  = double.Parse(collection["lan"]);
            searchCriteria.StartDate  = collection["checkIn"];
            searchCriteria.EndDate    = collection["checkOut"];
            searchCriteria.TotalGuest = collection["ddlTotalGuest"];
            searchCriteria.TotalRoom  = collection["ddlNoOfRooms"];
            searchCriteria.Provider   = collection["ddlProvider"];
            //Check in cache
            var key    = searchCriteria.Latitude.ToString() + searchCriteria.Longitude.ToString() + searchCriteria.StartDate.ToString() + searchCriteria.EndDate.ToString();
            var result = GetFromCache(key);

            if (result == null)
            {
                SearchHotel mgr = new SearchHotel();
                result = mgr.Search(searchCriteria);
                AddToCache(result, key);
            }
            ViewBag.StartDate       = searchCriteria.StartDate;
            ViewBag.EndDate         = searchCriteria.EndDate;
            ViewBag.TotalTravellers = searchCriteria.TotalGuest;
            ViewBag.Lat             = searchCriteria.Latitude;
            ViewBag.Lan             = searchCriteria.Longitude;
            return(View("SearchHotel", result));
        }
Esempio n. 2
0
        private HotelAvailabilityProviderReq ConvertToProviderReqeust(HotelSearchDto hotelDto)
        {
            HotelBedsSearchProvider      provider    = new HotelBedsSearchProvider();
            HotelAvailabilityProviderReq providerReq = new HotelAvailabilityProviderReq();

            if (hotelDto != null)
            {
                providerReq.CheckInDate = Convert.ToDateTime(hotelDto.StartDate);

                providerReq.CheckOutDate = Convert.ToDateTime(hotelDto.EndDate);
                providerReq.MaxRating    = hotelDto.MaxRating;
                providerReq.MinRating    = hotelDto.MinRating;

                //Hotel code should come from search manager class
                if (hotelDto.HotelCodes != null)
                {
                    providerReq.HotelCodes = hotelDto.HotelCodes;
                }

                else if (hotelDto.Latitude.ToString().Length > 0)
                {
                    providerReq.GeoLocation = new GeoLocation()
                    {
                        Latitude  = Convert.ToDecimal(hotelDto.Latitude),
                        Longitude = Convert.ToDecimal(hotelDto.Longitude)
                    };
                }
                //TODO:RoomDto
                //providerReq.TotalAdults = Convert.ToInt16(hotelDto.TotalGuest);
            }
            return(providerReq);
        }
        public ActionResult Index(string hotelCode)
        {
            selectedHotelCode = hotelCode;
            HotelSearchDto searchCriteria = TempData["HotelSearchDto"] as HotelSearchDto;

            //Call manager class and there make a call to provider based on selected ddl value(Provider)
            var provider       = HotelProviderBroker.GetHotelSearchProvider((HotelSearchProviderTypes)int.Parse(searchCriteria.Provider));
            var searchResponse = provider.RetrieveHotelRates(ConvertToProviderRequest(searchCriteria));


            return(View());
        }
        private HotelPropertyProviderReq ConvertToProviderRequest(HotelSearchDto hotelDto)
        {
            HotelPropertyProviderReq providerReq = new HotelPropertyProviderReq();

            if (hotelDto != null)
            {
                providerReq.CheckInDate  = Convert.ToDateTime(hotelDto.StartDate);
                providerReq.CheckOutDate = Convert.ToDateTime(hotelDto.EndDate);
                providerReq.HotelCode    = selectedHotelCode;
                providerReq.NoOfGuest    = Convert.ToInt16(hotelDto.TotalGuest);
            }
            return(providerReq);
        }
Esempio n. 5
0
        //
        // GET: /BBHotelDetails/

        public ActionResult Index(FormCollection collection)
        {
            HotelBedsDetailsHandler      hotelInfo   = new HotelBedsDetailsHandler();
            HotelAvailabilityProviderReq providerReq = new HotelAvailabilityProviderReq();
            HotelSearchDto searchCriteria            = new HotelSearchDto();

            searchCriteria.HotelCodes = collection["hotelCode"];
            searchCriteria.StartDate  = collection["checkIn"];
            searchCriteria.EndDate    = collection["checkOut"];
            Hotel hotelfiltered = new Hotel();

            providerReq.CheckInDate  = Convert.ToDateTime(collection["checkIn"]);
            providerReq.CheckOutDate = Convert.ToDateTime(collection["checkOut"]);
            providerReq.TotalAdults  = Convert.ToInt32(collection["totalTravellers"]);
            providerReq.TotalRooms   = Convert.ToInt32(collection["totalRooms"]);
            if (searchCriteria.HotelCodes.Length > 0)
            {
                providerReq.HotelCodes = searchCriteria.HotelCodes.Split(' ').ToList <string>();
            }
            var hotelinfoRS = hotelInfo.Execute(providerReq).Hotels.FirstOrDefault();

            return(View(hotelinfoRS));
        }
Esempio n. 6
0
        public ActionResult searchBedbank(FormCollection collection)
        {
            HotelSearchDto searchCriteria = new HotelSearchDto();

            searchCriteria.Provider = collection["ddlProvider"];

            searchCriteria.Address = collection["add"];
            if (collection["lat"] != "")
            {
                searchCriteria.Latitude = double.Parse(collection["lat"]);
            }
            if (collection["lan"] != "")
            {
                searchCriteria.Longitude = double.Parse(collection["lan"]);
            }
            searchCriteria.StartDate  = collection["checkIn"];
            searchCriteria.EndDate    = collection["checkOut"];
            searchCriteria.TotalGuest = collection["ddlTotalGuest"];
            searchCriteria.TotalRoom  = collection["ddlNoOfRooms"];
            searchCriteria.Provider   = collection["ddlProvider"];
            //if (collection["hotelcodes"] != "")
            searchCriteria.HotelCodes  = GetHotels(collection);
            TempData["HotelSearchDto"] = searchCriteria;
            //Call manager class and there make a call to provider based on selected ddl value(Provider)

            ViewBag.StartDate       = searchCriteria.StartDate;
            ViewBag.EndDate         = searchCriteria.EndDate;
            ViewBag.TotalTravellers = searchCriteria.TotalGuest;
            ViewBag.Lat             = searchCriteria.Latitude;
            ViewBag.Lan             = searchCriteria.Longitude;

            var provider       = HotelProviderBroker.GetHotelSearchProvider((HotelSearchProviderTypes)int.Parse(searchCriteria.Provider));
            var searchResponse = provider.Search(ConvertToProviderReqeust(searchCriteria));

            return(View("SearchHotelTourico", searchResponse));
        }
Esempio n. 7
0
        public OTA_HotelAvailRS Search(HotelSearchDto searchCriteria)
        {
            var session = SabreSessionManager.Create();
            OTA_HotelAvailRQ availability           = new OTA_HotelAvailRQ();
            OTA_HotelAvailRQAvailRequestSegment req = new OTA_HotelAvailRQAvailRequestSegment();
            OTA_HotelAvailRQAvailRequestSegmentHotelSearchCriteria crt =
                new OTA_HotelAvailRQAvailRequestSegmentHotelSearchCriteria();
            OTA_HotelAvailRQAvailRequestSegmentHotelSearchCriteriaCriterion cirterian =
                new OTA_HotelAvailRQAvailRequestSegmentHotelSearchCriteriaCriterion();

            OTA_HotelAvailRQAvailRequestSegmentHotelSearchCriteriaCriterionHotelRef[] refrs =
                new OTA_HotelAvailRQAvailRequestSegmentHotelSearchCriteriaCriterionHotelRef[1];
            OTA_HotelAvailRQAvailRequestSegmentHotelSearchCriteriaCriterionHotelRef ref1 =
                new OTA_HotelAvailRQAvailRequestSegmentHotelSearchCriteriaCriterionHotelRef();
            OTA_HotelAvailRQAvailRequestSegmentTimeSpan journeyDate =
                new OTA_HotelAvailRQAvailRequestSegmentTimeSpan();
            OTA_HotelAvailRQAvailRequestSegmentGuestCounts guest = new OTA_HotelAvailRQAvailRequestSegmentGuestCounts();
            Security1 sec = new Security1();
            OTA_HotelAvailRQAvailRequestSegmentPOS       pos    = new OTA_HotelAvailRQAvailRequestSegmentPOS();
            OTA_HotelAvailRQAvailRequestSegmentPOSSource source = new OTA_HotelAvailRQAvailRequestSegmentPOSSource();

            OTA_HotelAvailRQAvailRequestSegmentRatePlanCandidates ratePlan = new OTA_HotelAvailRQAvailRequestSegmentRatePlanCandidates();

            ratePlan.RateRange = new OTA_HotelAvailRQAvailRequestSegmentRatePlanCandidatesRateRange()
            {
                Min = "1"
            };

            if (searchCriteria.Address != null && searchCriteria.Address != string.Empty)
            {
                ref1.HotelCityCode = searchCriteria.Address;
            }

#pragma warning disable CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null'
            if (searchCriteria.Latitude != null && searchCriteria.Longitude != null)
#pragma warning restore CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null'
            {
                ref1.Latitude  = searchCriteria.Latitude.ToString("N2");
                ref1.Longitude = searchCriteria.Longitude.ToString("N2");
            }
            refrs[0]                = ref1;
            cirterian.HotelRef      = refrs;
            crt.Criterion           = cirterian;
            req.HotelSearchCriteria = crt;
            guest.Count             = searchCriteria.TotalGuest;
            req.GuestCounts         = guest;
            crt.NumProperties       = "30";

            //req.po
            var startDate = Convert.ToDateTime(searchCriteria.StartDate);
            var endDate   = Convert.ToDateTime(searchCriteria.EndDate);
            journeyDate.Start = startDate.ToString("MM-dd"); // .Month.ToString() + "-" + startDate.Day.ToString();
            journeyDate.End   = endDate.ToString("MM-dd");   //.Month.ToString() + "-" + endDate.Day.ToString();
            req.TimeSpan      = journeyDate;

            availability.AvailRequestSegment = req;

            OTA_HotelAvailService ss = new OTA_HotelAvailService();
            sec.BinarySecurityToken = session.SecurityValue.BinarySecurityToken;
            ss.Security             = sec;
            ss.MessageHeaderValue   = Get("OTA_HotelAvailLLSRQ", "");
            var          XMLRequest = Common.Utility.Serialize(availability);
            var          result     = ss.OTA_HotelAvailRQ(availability);
            SessionClose close      = new SessionClose();
            close.Close(session.SecurityValue.BinarySecurityToken);
            var XML = Common.Utility.Serialize(result);
            return(result);
        }
Esempio n. 8
0
        public ActionResult Index(string hotelNameOrCity, string checkinDate, string checkoutDate, string room, string adult, string child)
        {
            // DateTime checkinDateKey = checkinDate == null ? DateTime.Now : DateTime.Parse(checkinDate,System.Globalization.CultureInfo.InvariantCulture);
            //DateTime checkoutDateKey = checkoutDate == null ? DateTime.Now : DateTime.Parse(checkinDate, System.Globalization.CultureInfo.InvariantCulture);

            int  townId = 0;
            bool Iscity = false;

            if (hotelNameOrCity != null)
            {
                foreach (var cityItem in dbContext.TownV10)
                {
                    if (cityItem.TownName.ToLower().Trim() == hotelNameOrCity.ToLower().Trim())
                    {
                        townId = dbContext.TownV10.Where(x => x.TownName.ToLower().Trim() == hotelNameOrCity.ToLower().Trim()).FirstOrDefault().TownId;

                        Iscity = true;
                    }
                }
            }

            List <HotelSearchItem> hotelSearchList = null;

            if (Iscity)
            {
                hotelSearchList = (from hotel in dbContext.Hotels
                                   join city in dbContext.TownV10 on hotel.CityId equals city.TownId
                                   join hotelPhotos in dbContext.HotelPhotos on hotel.HotelId equals hotelPhotos.HotelId
                                   join hotelRooms in dbContext.HotelRooms on hotel.HotelId equals hotelRooms.HotelId
                                   join roomTypes in dbContext.RoomTypes on hotelRooms.RoomTypeId equals roomTypes.RoomTypeId
                                   where city.TownId == townId && hotelPhotos.OrderNumber == 1 && roomTypes.Title == "Standart Oda"
                                   select new { hotel, hotelPhotos, city, roomTypes, hotelRooms }).ToList()
                                  .GroupBy(x => x.hotel.HotelId).Select(h => new HotelSearchItem()
                {
                    CityName    = h.FirstOrDefault().city.TownName,
                    CountryName = "Türkiye",
                    //  Day = (checkoutDateKey.Day - checkinDateKey.Day) - 1,
                    Description     = h.FirstOrDefault().hotel.Description,
                    HotelId         = h.FirstOrDefault().hotel.HotelId,
                    HotelImage      = h.FirstOrDefault().hotelPhotos.Photo,
                    HotelName       = h.FirstOrDefault().hotel.Title,
                    Price           = h.FirstOrDefault().hotelRooms.Price,
                    RoomName        = h.FirstOrDefault().roomTypes.Title,
                    HotelStar       = h.FirstOrDefault().hotel.Star,
                    hotelProperties = dbContext.HotelPropertyConnects.Join(dbContext.HotelProperties, k => k.HotelPropertyId, p => p.HotelPropertyId, (p, k) => new { p, k }).ToList().Where(x => x.p.HotelId == h.FirstOrDefault().hotel.HotelId).Select(c => new HotelProperties()
                    {
                        HotelPropertyId = c.k.HotelPropertyId,
                        Title           = c.k.Title,
                        Icon            = c.k.Icon
                    }).ToList()
                }).ToList();
            }

            if (!Iscity)
            {
                hotelSearchList = (from hotel in dbContext.Hotels
                                   join city in dbContext.TownV10 on hotel.CityId equals city.TownId
                                   join hotelPhotos in dbContext.HotelPhotos on hotel.HotelId equals hotelPhotos.HotelId
                                   join hotelRooms in dbContext.HotelRooms on hotel.HotelId equals hotelRooms.HotelId
                                   join roomTypes in dbContext.RoomTypes on hotelRooms.RoomTypeId equals roomTypes.RoomTypeId
                                   where hotel.Title.ToLower().Contains(hotelNameOrCity.ToLower()) && hotelPhotos.OrderNumber == 1 && roomTypes.Title == "Standart Oda"
                                   select new { hotel, hotelPhotos, city, roomTypes, hotelRooms }).ToList()
                                  .GroupBy(x => x.hotel.HotelId).Select(h => new HotelSearchItem()
                {
                    CityName    = h.FirstOrDefault().city.TownName,
                    CountryName = "Türkiye",
                    //  Day = (checkoutDateKey.Day - checkinDateKey.Day) - 1,
                    Description     = h.FirstOrDefault().hotel.Description,
                    HotelId         = h.FirstOrDefault().hotel.HotelId,
                    HotelImage      = h.FirstOrDefault().hotelPhotos.Photo,
                    HotelName       = h.FirstOrDefault().hotel.Title,
                    Price           = h.FirstOrDefault().hotelRooms.Price,
                    RoomName        = h.FirstOrDefault().roomTypes.Title,
                    HotelStar       = h.FirstOrDefault().hotel.Star,
                    hotelProperties = dbContext.HotelPropertyConnects.Join(dbContext.HotelProperties, k => k.HotelPropertyId, p => p.HotelPropertyId, (p, k) => new { p, k }).ToList().Where(x => x.p.HotelId == h.FirstOrDefault().hotel.HotelId).Select(c => new HotelProperties()
                    {
                        HotelPropertyId = c.k.HotelPropertyId,
                        Title           = c.k.Title,
                        Icon            = c.k.Icon
                    }).ToList()
                }).ToList();
            }
            HotelSearchDto hotelSearchDto = new HotelSearchDto()
            {
                HotelProperties = dbContext.HotelProperties.ToList(),
                Districts       = dbContext.DistrictV10.Where(x => x.TownId == townId).Take(10).ToList(),
                //  checkinDate = checkinDateKey,
                //checkoutDate = checkoutDateKey,
                adult           = adult,
                child           = child,
                HotelCount      = hotelSearchList.Count(),
                CityName        = hotelSearchList.FirstOrDefault().CityName,
                CountryName     = hotelSearchList.FirstOrDefault().CountryName,
                hotelSearchList = hotelSearchList
            };

            return(View(hotelSearchDto));
        }
Esempio n. 9
0
        public ActionResult SearchHotel(FormCollection collection)
        {
            HotelSearchDto               hotelDto    = TempData["HotelSearchDto"] as HotelSearchDto;
            HotelBedsSearchProvider      provider    = new HotelBedsSearchProvider();
            HotelAvailabilityProviderReq providerReq = new HotelAvailabilityProviderReq();

            if (hotelDto != null)
            {
                // List<Tuple<string, string>> param;
                Availability avail = new Availability();
                //avail.checkIn = Convert.ToDateTime(collection["checkIn"]);
                avail.checkIn = Convert.ToDateTime(hotelDto.StartDate);
                //avail.checkOut = Convert.ToDateTime(collection["checkOut"]);
                avail.checkOut = Convert.ToDateTime(hotelDto.EndDate);
                //var address = collection["add"];
                var address = hotelDto.Address;
                ViewBag.checkIn  = avail.checkIn;
                ViewBag.checkOut = avail.checkOut;
                //avail.destination = "PMI";
                //avail.zone = 90;
                avail.language  = "CAS";
                avail.shiftDays = 2;
                AvailRoom room = new AvailRoom();
                //room.adults = Convert.ToInt32(collection["ddlTotalGuest"]);
                room.adults     = Convert.ToInt32(hotelDto.TotalGuest);
                ViewBag.GuestNo = room.adults;
                room.children   = 0;

                //Hotel code should come from search manager class
                if (hotelDto.HotelCodes != null)
                {
                    providerReq.HotelCodes = hotelDto.HotelCodes.Split(',').ToList <string>();
                }

                else if (hotelDto.Latitude.ToString().Length > 0)
                {
                    providerReq.GeoLocation = new HotelBeds.ServiceCatalogues.HotelCatalog.Dtos.GeoLocation()
                    {
                        Latitude  = Convert.ToDecimal(hotelDto.Latitude),
                        Longitude = Convert.ToDecimal(hotelDto.Longitude)
                    };
                }
                ViewBag.LatOrg          = hotelDto.Latitude;
                ViewBag.LanOrg          = hotelDto.Longitude;
                providerReq.TotalAdults = Convert.ToInt16(hotelDto.TotalGuest);
                ViewBag.TotalTravellers = providerReq.TotalAdults;
                providerReq.TotalRooms  = Convert.ToInt16(hotelDto.TotalRoom);
                ViewBag.TotalRooms      = providerReq.TotalRooms;
                try
                {
                    //Call provider not handler
                    var hotels = provider.Search(providerReq).Hotels;
                    if (hotels != null)
                    {
                        return(View(hotels));
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch (Exception ex)
                {
                    ViewBag.error = ex.Message;
                    return(View());
                }
            }
            else
            {
                return(View("Home"));
            }
        }