Esempio n. 1
0
        public void configureBeforeClass()
        {
            driver             = Browser.getBrowser("Chrome");
            loginPage          = new Login();
            hotel              = new HotelFlow();
            air                = new AirFlow();
            flightSearchResult = new FlightSearchResult();
            hotelSearchResult  = new HotelSearchResult();
            quote              = new Quote();
            reprice            = new RepriceBook();
            tsp                = new TSP();
            addTravelers       = new AddTravelers();

            payment = new Payment();
            logout  = new Logout();
        }
        public static List <HotelSearchResult> GetInitSearchResultDetails(List <Hotel> hotels)
        {
            var resultDetails = new List <HotelSearchResult>();

            foreach (var hotel in hotels)
            {
                var hotelDetails = new HotelSearchResult();
                hotelDetails.HotelName             = hotel.name;
                hotelDetails.HotelId               = hotel.id;
                hotelDetails.AddressLine1          = hotel.contact?.address?.line1;
                hotelDetails.City                  = hotel.contact?.address?.city.name;
                hotelDetails.State                 = hotel.contact?.address?.state.name;
                hotelDetails.CountryCode           = hotel.contact?.address?.countryCode;
                hotelDetails.ContentSupplierFamily = hotel.contentSupplierFamily;
                hotelDetails.CreatedOn             = DateTime.UtcNow;
                hotelDetails.HotelChain            = hotel.hotelChain?.Name;
                hotelDetails.Latitude              = hotel.geoCode?.lat;
                resultDetails.Add(hotelDetails);
            }
            return(resultDetails);
        }
Esempio n. 3
0
        public async Task <HotelSearchResult> SearchHotels(string hotelName, CancellationToken cancellationToken)
        {
            HotelSearchResult result = new HotelSearchResult
            {
                SearchName = hotelName
            };
            List <Task <List <HotelData> > > tasks = new List <Task <List <HotelData> > >();

            tasks.Add(SearchTopHotels(hotelName, cancellationToken));
            tasks.Add(SearchTripAdvisor(hotelName, cancellationToken));
            tasks.Add(SearchBooking(hotelName, cancellationToken));
            tasks.Add(SearchTezTour(hotelName, cancellationToken));
            await Task.WhenAll(tasks);

            foreach (Task <List <HotelData> > task in tasks)
            {
                List <HotelData> hotels = await task;
                result.Hotels.AddRange(hotels);
            }
            return(result);
        }
Esempio n. 4
0
        public async Task InsertSearchResultDetails(HotelSearchResult request)
        {
            var jsonSettings = new JsonSerializerSettings {
                ContractResolver = new LowercaseContractResolver()
            };

            jsonSettings.DateFormatString = "yyyy-MM-dd";
            var jsonRequest      = JsonConvert.SerializeObject(request, jsonSettings) + "\n";
            var requestByteCount = Encoding.UTF8.GetByteCount(jsonRequest);
            //Console.WriteLine($"Size of RESPONSE in bytes : {requestByteCount}");
            //Console.WriteLine(jsonRequest);
            Record record = new Record();

            record.Data = new MemoryStream(Encoding.UTF8.GetBytes(jsonRequest));
            PutRecordRequest putRecordRequest = new PutRecordRequest();

            putRecordRequest.DeliveryStreamName = KeyStore.FirehoseResultDetailsStream;
            putRecordRequest.Record             = record;
            var response = await _client.PutRecordAsync(putRecordRequest);

            Console.WriteLine($"{response.RecordId} , {response.HttpStatusCode}");
        }
        public HotelSearchResponse GetDataBySession(SearchData searchData)
        {
            try
            {
                #region Hotelbeds pid 5
                HotelSearchResponse hotelsSearch = new HotelSearchResponse();
                HotelRepo           repo         = new HotelRepo();
                hotelsDBEntities    dbh          = new hotelsDBEntities();

                using (SearchDBEntities db = new SearchDBEntities())
                {
                    int duration     = Convert.ToInt32((searchData.DateTo - searchData.DateFrom).TotalDays);
                    var HotelResults = db.SearchHotelResults.Where(a => a.sID == searchData.sID).ToList();
                    var providers    = HotelResults.GroupBy(x => x.ProviderID).Select(x => x.FirstOrDefault()).Select(a => a.ProviderID.Value).ToList();

                    var hotelIds = HotelResults.Select(a => a.HotelCode).ToList();

                    //List<HotelDetails> HotelDataList = repo.GetHotelData(hotelIds, "4");///
                    List <HotelDetails> HotelDataList = new List <HotelDetails>();
                    hotelsSearch.CheckIn  = searchData.DateFrom;
                    hotelsSearch.CheckOut = searchData.DateTo;

                    using (var _TBOContext = new TBOContext())
                    {
                        List <Image> imagesdata = (from i in _TBOContext.HotelImages

                                                   //  join i in dbh.HotelsImages on h.hotelID equals i.HotelID
                                                   where hotelIds.Contains(i.HotelCode)
                                                   select new Image()
                        {
                            Thum = i.URL,
                            HotelId = i.HotelCode,
                            Category = "",
                            Url = i.URL
                        }).ToList();

                        //List<HotelsAmenity> imagesdata = (from i in _TBOContext.Facilities

                        //                              //  join i in dbh.HotelsImages on h.hotelID equals i.HotelID
                        //                          where hotelIds.Contains(i.HotelCode)
                        //                          select new Image()
                        //                          {


                        //                          }).ToList();

                        /*     List<HotelAmenity> amenties = (from h in dbh.hotels
                         *
                         *                                  join A in dbh.HotelsAmenities on h.hotelID equals A.hotelID
                         *                                  where hotelIds.Contains(h.hotelID)
                         *                                  select new HotelAmenity()
                         *                                  {
                         *                                      Amenity = A.amenitie,
                         *                                      HotelCode = h.hotelID,
                         *                                      status = A.Status
                         *                                  }).ToList();*/
                        var list = (from h in _TBOContext.HotelDetails

                                    where hotelIds.Contains(h.HotelCode)
                                    select new HotelDetails()
                        {
                            ID = h.HotelDetailId,
                            HotelId = h.HotelCode,
                            Address = h.Address,
                            Rating = h.HotelRating,
                            HotelName = h.HotelName,
                            Zipcode = h.PinCode,
                            //ProviderHotelId = h.h,
                            //  ProviderID = p.providerID,
                            Location = h.HotelLocation,
                            ShortDescription = h.Description,
                            LongDescriptin = h.Description,
                            City = h.CityName,
                            Country = h.CountryName,
                            //Lat = h.,
                            //Lng = h.,
                            Location1 = h.HotelLocation,
                            Location2 = h.HotelLocation,
                            Location3 = h.HotelLocation


                                        //{ images.Where(a => a.HotelId == h.hotelID).ToList() }
                        }).Distinct().ToList();

                        /*    foreach (var item in list)
                         *  {
                         *      List<HotelAmenity> ams = new List<HotelAmenity>();
                         *      var hotelAmenities = amenties.Where(a => a.HotelCode == item.HotelId).Distinct().ToList();
                         *      foreach (var am in hotelAmenities)
                         *      {
                         *
                         *          am.Amenity = am.Amenity.Replace(" ", String.Empty);
                         *          if (ams.FirstOrDefault(x => x.Amenity == am.Amenity) == null)
                         *          {
                         *              ams.Add(am);
                         *          }
                         *      }
                         *      item.hotelAmenities = ams;
                         *  }*/
                        var stars = new List <string> {
                            "OneStar", "TwoStar", "ThreeStar", "FourStar", "FiveStar"
                        };

                        list.ForEach(a => a.Images = imagesdata.Where(h => h.HotelId == a.HotelId).ToList());
                        HotelDataList.AddRange(list);
                        foreach (var item in HotelResults)
                        {
                            HotelSearchResult hotel     = new HotelSearchResult();
                            HotelDetails      hotelData = HotelDataList.Where(a => a.HotelId == item.HotelCode).FirstOrDefault();

                            if (hotelData != null)
                            {
                                hotel.providerHotelCode = item.ProviderHotelCode;
                                hotel.City      = hotelData.City;
                                hotel.hotelName = hotelData.HotelName;

                                hotel.Country    = hotelData.Country;
                                hotel.hotelStars = stars.IndexOf(hotelData.Rating);
                                var images = hotelData.Images.FirstOrDefault();
                                if (images != null)
                                {
                                    hotel.hotelThumb = images.Thum;
                                }
                                //***   hotel.hotelImages = hotelData.Images.Select(a => a.Url).ToList();
                                //**     hotel.Amenities = hotelData.hotelAmenities;
                                hotel.Lat                      = hotelData.Lat ?? "";
                                hotel.Lng                      = hotelData.Lng ?? "";
                                hotel.providerID               = item.ProviderID.Value.ToString();
                                hotel.hotelDescription         = hotelData.LongDescriptin;
                                hotel.shortcutHotelDescription = hotelData.ShortDescription;
                                hotel.ZipCode                  = hotelData.Zipcode ?? "";
                                hotel.Location                 = hotelData.Location;
                                hotel.Address                  = hotelData.Address;
                                hotel.providerHotelID          = item.ProviderHotelId;
                                hotel.hotelCode                = hotelData.HotelId;
                                hotel.sellCurrency             = searchData.Currency;

                                hotel.hotelRate      = item.SellPrice.Value / duration;
                                hotel.costPrice      = item.CostPrice.Value;
                                hotel.TotalSellPrice = item.SellPrice.Value;
                                hotel.rooms          = new List <RoomResult>();
                                hotelsSearch.HotelResult.Add(hotel);
                            }
                        }
                    }
                }
                hotelsSearch.Locations = hotelsSearch.HotelResult.GroupBy(x => x.Location).Select(x => x.FirstOrDefault()).Select(a => a.Location).ToList();

                return(hotelsSearch);

                #endregion
            }catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Select the cheapest hotel from the available hotels and get the details of the selected hotel
        /// </summary>
        /// <param name="hotelResponse"></param>
        /// <returns></returns>
        ///

        public HotelDetailsRsp HotelDetails(BaseHotelSearchRsp hotelResponse)
        {
            HotelSearchResult closest  = null;
            HotelSearchResult cheapest = null;

            int    lowestDistance = Int32.MaxValue;
            double lowestPrice    = Int32.MaxValue;

            IEnumerator <HotelSearchResult> searchResults = hotelResponse.HotelSearchResult.ToList().GetEnumerator();

            while (searchResults.MoveNext())
            {
                HotelSearchResult result = searchResults.Current;
                IEnumerator <HotelService.HotelProperty> hotelProperties = result.HotelProperty.ToList().GetEnumerator();
                if (result.RateInfo != null && result.RateInfo.Count() > 0)
                {
                    while (hotelProperties.MoveNext())
                    {
                        HotelService.HotelProperty property = hotelProperties.Current;
                        if (property.Availability.CompareTo(HotelService.typeHotelAvailability.Available) == 0)
                        {
                            if (property.ReserveRequirement.CompareTo(HotelService.typeReserveRequirement.Other) == 0)
                            {
                                continue;
                            }

                            if (property.Distance != null) //check lowest distance for closet hotel from the reference point
                            {
                                int distance = Convert.ToInt32(property.Distance.Value);
                                if (distance < lowestDistance)
                                {
                                    ClosestHotelCode = property.HotelCode;
                                    closest          = result;
                                    lowestDistance   = distance;
                                }
                            }

                            IEnumerator <RateInfo> hotelRates = result.RateInfo.ToList().GetEnumerator();
                            while (hotelRates.MoveNext())
                            {
                                RateInfo rate    = hotelRates.Current;
                                double   minRate = 0.0;
                                if (rate.MinimumAmount != null)
                                {
                                    minRate = Helper.parseNumberWithCurrency(rate.MinimumAmount);
                                }
                                else if (rate.ApproximateMinimumStayAmount != null)
                                {
                                    minRate = Helper.parseNumberWithCurrency(rate.ApproximateMinimumStayAmount);
                                }
                                else if (rate.ApproximateMinimumAmount != null)
                                {
                                    minRate = Helper.parseNumberWithCurrency(rate.ApproximateMinimumAmount);
                                }

                                if (minRate == 0.0)
                                {
                                    if (rate.MaximumAmount != null)
                                    {
                                        minRate = Helper.parseNumberWithCurrency(rate.MaximumAmount) / 2;
                                    }
                                    else if (rate.ApproximateMinimumAmount != null)
                                    {
                                        minRate = Helper.parseNumberWithCurrency(rate.ApproximateMinimumAmount) / 2;
                                    }
                                    else if (rate.ApproximateMaximumAmount != null)
                                    {
                                        minRate = Helper.parseNumberWithCurrency(rate.ApproximateMaximumAmount) / 2;
                                    }
                                }

                                if (minRate < lowestPrice)/// Check the lowest price
                                {
                                    CheapestHotelCode = property.HotelCode;
                                    cheapest          = result;
                                    lowestPrice       = minRate;
                                    if (rate.RateSupplier != null)
                                    {
                                        RateSupplier = rate.RateSupplier;
                                    }
                                }
                            }
                        }
                    }
                }
            }


            if (hotelResponse.HostToken != null)
            {
                hostToken = hotelResponse.HostToken;
            }

            if (closest == null)
            {
                HotelSearchResult[] hotelSearchResult = new HotelSearchResult[1];
                hotelSearchResult[0] = cheapest;
            }

            HotelSearchResult[] hotelSearchResultBoth = new HotelSearchResult[2];
            hotelSearchResultBoth[0] = cheapest;
            hotelSearchResultBoth[1] = closest;


            HotelDetailsReq detailsRequest = new HotelDetailsReq();

            detailsRequest.TargetBranch     = CommonUtility.GetConfigValue(ProjectConstants.G_TARGET_BRANCH);
            detailsRequest.TraceId          = "Trace";
            detailsRequest.AuthorizedBy     = "User";
            detailsRequest.ReturnMediaLinks = true;

            HotelService.BillingPointOfSaleInfo billSaleInfo = new HotelService.BillingPointOfSaleInfo();
            billSaleInfo.OriginApplication = CommonUtility.GetConfigValue(ProjectConstants.APP);

            detailsRequest.BillingPointOfSaleInfo = billSaleInfo;
            detailsRequest.HotelProperty          = cheapest.HotelProperty[0];// Cheapsest hotel selected

            HotelService.HotelDetailsModifiers hotelDetailsModifiers = new HotelService.HotelDetailsModifiers();
            hotelDetailsModifiers.HotelStay          = GetHotelStay();
            hotelDetailsModifiers.NumberOfAdults     = numberOfAdults;
            hotelDetailsModifiers.NumberOfRooms      = numberOfRooms;
            hotelDetailsModifiers.RateRuleDetail     = HotelService.typeRateRuleDetail.Complete;
            hotelDetailsModifiers.PermittedProviders = new HotelService.PermittedProviders()
            {
                Provider = new HotelService.Provider()
                {
                    Code = providerCode
                }
            };

            detailsRequest.HotelDetailsModifiers = hotelDetailsModifiers;


            HotelDetailsServicePortTypeClient detailsClient = new HotelDetailsServicePortTypeClient("HotelDetailsServicePort", WsdlService.HOTEL_ENDPOINT);

            detailsClient.ClientCredentials.UserName.UserName = Helper.RetrunUsername();
            detailsClient.ClientCredentials.UserName.Password = Helper.ReturnPassword();

            try
            {
                var httpHeaders = Helper.ReturnHttpHeader();
                detailsClient.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders));

                detailsResponse = detailsClient.service(detailsRequest);
            }
            catch (Exception se)
            {
                detailsClient.Abort();
            }

            HotelRulesRsp hotelRulesResponse = HotelRules(cheapest.HotelProperty[0]);

            return(detailsResponse);
        }
Esempio n. 7
0
        // map rooms ??????!!!!!!!!!!!!!!
        public HotelSearchResponse MapSearchResult(List <Hotel> searchOutputs, SearchData searchData)
        {
            try
            {
                //save result
                //apply salesRules
                HotelSearchResponse searchResponse            = new HotelSearchResponse();
                CurrencyManager     currencyManager           = new CurrencyManager();
                SalesRulesManager   ServiceChargeManager      = new SalesRulesManager();
                SalesRulesManager   CancellationChargeManager = new SalesRulesManager();
                var BaseCur = ConfigurationSettings.AppSettings["BaseCur"];

                //start sales rules service charge
                ServiceChargeManager.FillSalesRules(searchData.POS, "Hotel", "Service Charge"); //1
                ServiceChargeManager.PrepareSearchCriteriaDic(searchData);                      //2
                ////
                ///cancellation charge
                CancellationChargeManager.FillSalesRules(searchData.POS, "Hotel", "Cancellation Charge");
                CancellationChargeManager.PrepareSearchCriteriaDic(searchData);
                //

                List <string>            hotelIds      = searchOutputs.Select(a => a.code.ToString()).ToList();
                HotelManager             manager       = new HotelManager();
                List <HotelDetails>      HotelDataList = manager.GetHotelData(hotelIds, "4");
                List <HotelSearchResult> results       = new List <HotelSearchResult>();
                double ProviderExcahngeRate            = currencyManager.GetCurrencyConversion(searchOutputs[0].currency, BaseCur, searchData.sID);
                ////////////double ProviderExcahngeRate = currencyManager.GetCurrencyConversion("EUR", BaseCur);/////MG
                double ExcahngeRate = currencyManager.GetCurrencyConversion(BaseCur, searchData.Currency, searchData.sID);
                //  searchResponse.Locations = HotelDataList.GroupBy(x => x.Location).Select(x => x.FirstOrDefault()).Select(a=>a.Location).ToList();

                int duration = Convert.ToInt32((searchData.DateTo - searchData.DateFrom).TotalDays);
                {
                    DateTime CheckInDate = searchData.DateFrom;
                    for (int i = 0; i < searchOutputs.Count; i++)
                    {
                        HotelDetails      hotelData = HotelDataList.Where(a => a.ProviderHotelId == searchOutputs[i].code.ToString()).FirstOrDefault();
                        HotelSearchResult hotel     = new HotelSearchResult();
                        if (hotelData != null)
                        {
                            hotel.providerHotelCode = searchOutputs[i].code.ToString();
                            hotel.City      = hotelData.City;
                            hotel.hotelName = hotelData.HotelName;

                            hotel.Country    = hotelData.Country;
                            hotel.hotelStars = int.Parse(hotelData.Rating);
                            var images = hotelData.Images.FirstOrDefault();
                            if (images != null)
                            {
                                hotel.hotelThumb = images.Thum;
                            }
                            //***    hotel.hotelImages = hotelData.Images.Select(a => a.Url).ToList();
                            hotel.Amenities                = hotelData.hotelAmenities;
                            hotel.Lat                      = hotelData.Lat;
                            hotel.Lng                      = hotelData.Lng;
                            hotel.providerID               = "4";
                            hotel.hotelDescription         = hotelData.LongDescriptin;
                            hotel.shortcutHotelDescription = hotelData.ShortDescription;
                            hotel.ZipCode                  = hotelData.Zipcode;
                            hotel.Location                 = hotelData.Location;
                            hotel.Address                  = hotelData.Address;
                            hotel.providerHotelID          = hotelData.ProviderHotelId;
                            hotel.hotelCode                = hotelData.HotelId;
                            hotel.sellCurrency             = searchData.Currency;

                            hotel.costCurrency = searchOutputs[i].currency;
                            //set sales rules cirtiera
                            //  hotel.hotelRate = ((hotel.costPrice)+ AppliedMarkup.Value-AppliedDiscount.Value)* ExcahngeRate;

                            hotel.rooms = new List <RoomResult>();

                            AppliedSalesRule AppliedCancellationMarkup = CancellationChargeManager.ApplySalesRules("Markup");

                            for (int j = 0; j < searchOutputs[i].rooms.Count; j++)
                            {
                                for (int x = 0; x < searchOutputs[i].rooms[j].rates.Count; x++)
                                {
                                    RoomResult room = new RoomResult();

                                    if (searchOutputs[i].rooms[j].rates[x].net == null)
                                    {
                                        continue;
                                    }
                                    room.CostPrice  = Math.Round(double.Parse(searchOutputs[i].rooms[j].rates[x].net), 3);
                                    hotel.costPrice = room.CostPrice;
                                    CancellationChargeManager.SetResultCriteria(hotel.hotelName, hotel.hotelStars, hotel.costPrice, "4");
                                    ServiceChargeManager.SetResultCriteria(hotel.hotelName, hotel.hotelStars, room.CostPrice
                                                                           * ProviderExcahngeRate, "4");
                                    AppliedSalesRule AppliedMarkup   = ServiceChargeManager.ApplySalesRules("Markup");
                                    AppliedSalesRule AppliedDiscount = ServiceChargeManager.ApplySalesRules("Discount");

                                    //  room.IsRefundable = searchOutputs[i].rooms[j].refundable;
                                    ////******
                                    room.RatePerNight = ((room.CostPrice * ProviderExcahngeRate / duration) + AppliedMarkup.Value - AppliedDiscount.Value) * ExcahngeRate;
                                    room.RatePerNight = Math.Round(room.RatePerNight, 3);

                                    room.TotalSellPrice = Math.Round(room.RatePerNight * duration, 3);

                                    room.RoomIndex     = j + 1;                                      // index front use
                                    room.RoomReference = searchOutputs[i].rooms[j].rates[x].rateKey; // reference of provider
                                    /////
                                    room.RoomCode = searchOutputs[i].rooms[j].code;
                                    /////////
                                    room.RoomType = searchOutputs[i].rooms[j].name; // standard or double
                                    ///////
                                    room.RoomMeal     = searchOutputs[i].rooms[j].rates[x].boardName;
                                    room.Adult        = searchOutputs[i].rooms[j].rates[x].adults;
                                    room.Child        = searchOutputs[i].rooms[j].rates[x].children;
                                    room.IsRefundable = searchOutputs[i].rooms[j].rates[x].rateClass == "NRF"?false:true;

                                    ///////
                                    room.Paxs = searchOutputs[i].rooms[j].rates[x].adults + searchOutputs[i].rooms[j].rates[x].children;
                                    //***   room.Images = hotelData.Images.Where(a => a.Category.ToLower() == "hotel rooms").Select(a => a.Url).ToList();
                                    room.DiscountId        = AppliedDiscount.ID;
                                    room.MarkupId          = AppliedMarkup.ID;
                                    room.DiscountValue     = AppliedDiscount.Value * ExcahngeRate;
                                    room.MarkupValue       = AppliedMarkup.Value * ExcahngeRate;
                                    room.rateClass         = searchOutputs[i].rooms[j].rates[x].rateClass;
                                    room.rateType          = searchOutputs[i].rooms[j].rates[x].rateType;
                                    room.childrenAges      = searchOutputs[i].rooms[j].rates[x].childrenAges;
                                    room.paymentType       = searchOutputs[i].rooms[j].rates[x].paymentType;
                                    room.boardCode         = searchOutputs[i].rooms[j].rates[x].boardCode;
                                    room.cancellationRules = searchOutputs[i].rooms[j].rates[x].cancellationPolicies == null ?
                                                             new List <CancellationRule>()
                                    {
                                        new CancellationRule
                                        {
                                            Cost = 0, Price = 0, CanellationRuleText = null, FromDate = null, ToDate = null
                                        }
                                    } :
                                    searchOutputs[i].rooms[j].rates[x].cancellationPolicies.Select(a => new CancellationRule
                                    {
                                        Price = Math.Round(((double.Parse(a.amount) * ProviderExcahngeRate) + AppliedCancellationMarkup.Value) * ExcahngeRate, 3),
                                        CanellationRuleText = searchData.Lang.ToLower() == "en" ? Math.Round(((double.Parse(a.amount) * ProviderExcahngeRate) + AppliedCancellationMarkup.Value) * ExcahngeRate, 3) + "" + searchData.Currency + " To " + a.from : a.from + " إلى " + "" + searchData.Currency + Math.Round(((double.Parse(a.amount) * ProviderExcahngeRate) /*+ AppliedCancellationMarkup.Value*/) * ExcahngeRate, 3),
                                        Cost     = Math.Round(double.Parse(a.amount)),
                                        FromDate = a.from.ToString()
                                    }).ToList();
                                    hotel.rooms.Add(room);
                                }
                            }

                            var minRoom = hotel.rooms.Where(a => a.RatePerNight == hotel.rooms.Min(x => x.RatePerNight)).FirstOrDefault();
                            if (minRoom != null)
                            {
                                hotel.hotelRate      = minRoom.RatePerNight;
                                hotel.costPrice      = minRoom.CostPrice;
                                hotel.TotalSellPrice = minRoom.TotalSellPrice;
                                hotel.MarkupId       = minRoom.MarkupId;
                                hotel.MarkupValue    = minRoom.MarkupValue;
                                hotel.DiscountId     = minRoom.DiscountId;
                                hotel.DiscountValue  = minRoom.DiscountValue;
                            }
                            results.Add(hotel);
                        }
                    }

                    searchResponse.HotelResult = results;
                    return(searchResponse);
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.WriteToFile("MapSearchResult/Errors/", "MapSearchResult_" + searchData.sID, ex.Message, ex.Message + " Sourse :" + ex.Source + " Stack Trace :" + ex.StackTrace);
                return(new HotelSearchResponse());
            }
        }
Esempio n. 8
0
        public HotelSearchResponse MapSearchResult(List <PropertyResult> searchOutputs, SearchData searchData)
        {
            try
            {
                //    var json = new JavaScriptSerializer().Serialize(obj);
                //save result
                //apply salesRules
                HotelSearchResponse searchResponse            = new HotelSearchResponse();
                CurrencyManager     currencyManager           = new CurrencyManager();
                SalesRulesManager   ServiceChargeManager      = new SalesRulesManager();
                SalesRulesManager   CancellationChargeManager = new SalesRulesManager();

                //start sales rules service charge
                ServiceChargeManager.FillSalesRules(searchData.POS, "Hotel", "Service Charge");
                ServiceChargeManager.PrepareSearchCriteriaDic(searchData);
                ////
                /////cancellation charge
                CancellationChargeManager.FillSalesRules(searchData.POS, "Hotel", "Cancellation Charge");
                CancellationChargeManager.PrepareSearchCriteriaDic(searchData);
                //
                var BaseCur = ConfigurationSettings.AppSettings["BaseCur"];

                List <string>            hotelIds      = searchOutputs.Select(a => a.PropertyReferenceID).ToList();
                HotelManager             manager       = new HotelManager();
                List <HotelDetails>      HotelDataList = manager.GetHotelData(hotelIds, "2");
                List <HotelSearchResult> results       = new List <HotelSearchResult>();
                /////double ProviderExcahngeRate = currencyManager.GetCurrencyConversion("USD", BaseCur);
                double ProviderExcahngeRate = currencyManager.GetCurrencyConversion(searchData.Currency, BaseCur, searchData.sID);
                double ExcahngeRate         = currencyManager.GetCurrencyConversion(BaseCur, searchData.Currency, searchData.sID);
                //  searchResponse.Locations = HotelDataList.GroupBy(x => x.Location).Select(x => x.FirstOrDefault()).Select(a => a.Location).ToList();

                int duration = Convert.ToInt32((searchData.DateTo - searchData.DateFrom).TotalDays);
                {
                    DateTime CheckInDate = searchData.DateFrom;
                    for (int i = 0; i < searchOutputs.Count; i++)
                    {
                        HotelDetails      hotelData = HotelDataList.Where(a => a.ProviderHotelId == searchOutputs[i].PropertyReferenceID.ToString()).FirstOrDefault();
                        HotelSearchResult hotel     = new HotelSearchResult();
                        if (hotelData != null)
                        {
                            hotel.providerHotelCode = searchOutputs[i].PropertyID.ToString();
                            hotel.City       = hotelData.City;
                            hotel.hotelName  = hotelData.HotelName;
                            hotel.Country    = hotelData.Country;
                            hotel.hotelStars = int.Parse(hotelData.Rating) > 0 ? int.Parse(hotelData.Rating) - 558 : 0;
                            var images = hotelData.Images.FirstOrDefault();
                            if (images != null)
                            {
                                hotel.hotelThumb = images.Thum;
                            }
                            hotel.hotelImages              = hotelData.Images.Select(a => a.Thum).ToList();
                            hotel.Amenities                = hotelData.hotelAmenities;
                            hotel.Lat                      = hotelData.Lat;
                            hotel.Lng                      = hotelData.Lng;
                            hotel.providerID               = "2";
                            hotel.hotelDescription         = hotelData.LongDescriptin;
                            hotel.shortcutHotelDescription = hotelData.ShortDescription;
                            hotel.ZipCode                  = hotelData.Zipcode;
                            hotel.Location                 = hotelData.Location;
                            hotel.Address                  = hotelData.Address;
                            hotel.providerHotelID          = hotelData.ProviderHotelId;
                            hotel.hotelCode                = hotelData.HotelId;
                            hotel.sellCurrency             = searchData.Currency;
                            //  hotel.costPrice =//Math.Round( (double.Parse(searchOutputs[i].price.net.Value.ToString()) * ProviderExcahngeRate) /duration,3);
                            hotel.costCurrency = "USD";
                            //set sales rules cirtiera
                            //  hotel.hotelRate = ((hotel.costPrice)+ AppliedMarkup.Value-AppliedDiscount.Value)* ExcahngeRate;

                            hotel.rooms = new List <RoomResult>();
                            CancellationChargeManager.SetResultCriteria(hotel.hotelName, hotel.hotelStars, hotel.costPrice, "4");
                            AppliedSalesRule AppliedCancellationMarkup = CancellationChargeManager.ApplySalesRules("Markup");

                            for (int j = 0; j < searchOutputs[i].RoomTypes.RoomType.Count; j++)
                            {
                                RoomResult room = new RoomResult();

                                room.CostPrice = Math.Round(double.Parse(searchOutputs[i].RoomTypes.RoomType[j].Total), 3);

                                ServiceChargeManager.SetResultCriteria(hotel.hotelName, hotel.hotelStars, room.CostPrice
                                                                       * ProviderExcahngeRate, "2");
                                AppliedSalesRule AppliedMarkup   = ServiceChargeManager.ApplySalesRules("Markup");
                                AppliedSalesRule AppliedDiscount = ServiceChargeManager.ApplySalesRules("Discount");

                                //  room.IsRefundable = searchOutputs[i].rooms[j].refundable;
                                ////******
                                room.RatePerNight = ((room.CostPrice * ProviderExcahngeRate / duration) + AppliedMarkup.Value - AppliedDiscount.Value) * ExcahngeRate;
                                room.RatePerNight = Math.Round(room.RatePerNight, 3);

                                room.TotalSellPrice = Math.Round(room.RatePerNight * duration, 3);
                                room.RoomIndex      = j + 1;
                                room.RoomReference  = searchOutputs[i].RoomTypes.RoomType[j].PropertyRoomTypeID;
                                /////
                                room.RoomCode = searchOutputs[i].RoomTypes.RoomType[j].Seq;    //
                                /////////
                                room.RoomType     = searchOutputs[i].RoomTypes.RoomType[j].RoomTyper;
                                room.IsRefundable = searchOutputs[i].RoomTypes.RoomType[j].RoomTyper.Contains("Non-Refundable") || searchOutputs[i].RoomTypes.RoomType[j].RoomTyper.Contains("Non Refundable")?false:true;
                                room.MealID       = searchOutputs[i].RoomTypes.RoomType[j].MealBasisID;
                                ///////
                                room.RoomMeal     = searchOutputs[i].RoomTypes.RoomType[j].MealBasis;
                                room.Adult        = int.Parse(searchOutputs[i].RoomTypes.RoomType[j].Adults);
                                room.Child        = int.Parse(searchOutputs[i].RoomTypes.RoomType[j].Children);
                                room.BookingKeyTS = searchOutputs[i].RoomTypes.RoomType[j].BookingToken;
                                ///////
                                room.Paxs              = int.Parse(searchOutputs[i].RoomTypes.RoomType[j].Adults) + int.Parse(searchOutputs[i].RoomTypes.RoomType[j].Children);
                                room.Images            = hotelData.Images.Where(a => a.Category.ToLower() == "hotel rooms").Select(a => a.Thum).ToList();
                                room.DiscountId        = AppliedDiscount.ID;
                                room.MarkupId          = AppliedMarkup.ID;
                                room.DiscountValue     = AppliedDiscount.Value * ExcahngeRate;
                                room.MarkupValue       = AppliedMarkup.Value * ExcahngeRate;
                                room.cancellationRules = null;

                                /* room.cancellationRules = searchOutputs[i].rooms[j].rates[x].cancellationPolicies == null ? new List<CancellationRule>() { new CancellationRule { Cost = Math.Round((AppliedCancellationMarkup.Value) * ExcahngeRate, 3) } } :
                                 * searchOutputs[i].rooms[j].rates[x].cancellationPolicies.Select(a => new CancellationRule
                                 * {
                                 *
                                 *   Cost = Math.Round(((double.Parse(a.amount) * ProviderExcahngeRate) + AppliedCancellationMarkup.Value) * ExcahngeRate, 3),
                                 *   CanellationRuleText = searchData.Lang.ToLower() == "en" ? Math.Round(((double.Parse(a.amount) * ProviderExcahngeRate) + AppliedCancellationMarkup.Value) * ExcahngeRate, 3) + "" + searchData.Currency + " To " + a.from : a.from + " إلى " + "" + searchData.Currency + Math.Round(((double.Parse(a.amount) * ProviderExcahngeRate) + AppliedCancellationMarkup.Value) * ExcahngeRate, 3)
                                 * }).ToList();*/
                                hotel.rooms.Add(room);
                            }

                            var minRoom = hotel.rooms.Where(a => a.RatePerNight == hotel.rooms.Min(x => x.RatePerNight)).FirstOrDefault();
                            if (minRoom != null)
                            {
                                hotel.hotelRate      = minRoom.RatePerNight;
                                hotel.costPrice      = minRoom.CostPrice;
                                hotel.TotalSellPrice = minRoom.TotalSellPrice;
                                hotel.MarkupId       = minRoom.MarkupId;
                                hotel.MarkupValue    = minRoom.MarkupValue;
                                hotel.DiscountId     = minRoom.DiscountId;
                                hotel.DiscountValue  = minRoom.DiscountValue;
                            }
                            results.Add(hotel);
                        }
                    }
                    searchResponse.HotelResult = results;
                    return(searchResponse);
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.WriteToFile("SearchController/MapSearchResultTS/Errors/", "MapSearchResult_" + searchData.sID, ex.Message, ex.Message + " Sourse :" + ex.Source + " Stack Trace :" + ex.StackTrace);
                return(new HotelSearchResponse());
            }
        }
        /// <summary>
        /// Select the cheapest hotel from the available hotels and get the details of the selected hotel
        /// </summary>
        /// <param name="hotelResponse"></param>
        /// <returns></returns>
        public HotelDetailsRsp HotelDetails(BaseHotelSearchRsp hotelResponse)
        {

            HotelSearchResult closest = null;
            HotelSearchResult cheapest = null;

            int lowestDistance = Int32.MaxValue;
            double lowestPrice = Int32.MaxValue;

            IEnumerator<HotelSearchResult> searchResults = hotelResponse.HotelSearchResult.ToList().GetEnumerator();
            while (searchResults.MoveNext())
            {
                HotelSearchResult result = searchResults.Current;
                IEnumerator<HotelService.HotelProperty> hotelProperties = result.HotelProperty.ToList().GetEnumerator();
                if(result.RateInfo != null && result.RateInfo.Count() > 0)
                {
                    while (hotelProperties.MoveNext())
                    {
                        HotelService.HotelProperty property = hotelProperties.Current;
                        if (property.ReserveRequirement.CompareTo(HotelService.typeReserveRequirement.Other) == 0)
                        {
                                continue;
                        }

                        if (property.Distance != null)//check lowest distance for closet hotel from the reference point
                        {
                            int distance = Convert.ToInt32(property.Distance.Value);
                            if (distance < lowestDistance)
                            {
                                ClosestHotelCode = property.HotelCode;
                                closest = result;
                                lowestDistance = distance;
                            }
                        }


                        IEnumerator<RateInfo> hotelRates = result.RateInfo.ToList().GetEnumerator();
                        while (hotelRates.MoveNext())
                        {
                            RateInfo rate = hotelRates.Current;
                            double minRate = 0.0;
                            if (rate.MinimumAmount != null)
                            {
                                minRate = Helper.parseNumberWithCurrency(rate.MinimumAmount);
                            }
                            else if (rate.ApproximateMinimumStayAmount != null)
                            {
                                minRate = Helper.parseNumberWithCurrency(rate.ApproximateMinimumStayAmount);
                            }
                            else if (rate.ApproximateMinimumAmount != null)
                            {
                                minRate = Helper.parseNumberWithCurrency(rate.ApproximateMinimumAmount);
                            }

                            if (minRate == 0.0)
                            {
                                if (rate.MaximumAmount != null)
                                {
                                    minRate = Helper.parseNumberWithCurrency(rate.MaximumAmount)/2;
                                }
                                else if (rate.ApproximateAverageMinimumAmount != null)
                                {
                                    minRate = Helper.parseNumberWithCurrency(rate.ApproximateAverageMinimumAmount)/2;
                                }
                                else if (rate.ApproximateMaximumAmount != null)
                                {
                                    minRate = Helper.parseNumberWithCurrency(rate.ApproximateMaximumAmount)/2;
                                }

                            }

                            if (minRate < lowestPrice)/// Check the lowest price
                            {
                                CheapestHotelCode = property.HotelCode;
                                cheapest = result;
                                lowestPrice = minRate;
                                if (rate.RateSupplier != null)
                                {
                                    RateSupplier = rate.RateSupplier;
                                }
                            }
                        }

                    }

                }
            }


             if (hotelResponse.HostToken != null)
            {
                hostToken = hotelResponse.HostToken;
            }

            if (closest == null)
            {
                HotelSearchResult[] hotelSearchResult = new HotelSearchResult[1];
                hotelSearchResult[0] = cheapest;                
            }

            HotelSearchResult[] hotelSearchResultBoth = new HotelSearchResult[2];
            hotelSearchResultBoth[0] = cheapest;
            hotelSearchResultBoth[1] = closest;


            HotelDetailsReq detailsRequest = new HotelDetailsReq();
            detailsRequest.TargetBranch = CommonUtility.GetConfigValue(ProjectConstants.G_TARGET_BRANCH);
            detailsRequest.TraceId = "Trace";
            detailsRequest.AuthorizedBy = "User";
            detailsRequest.ReturnMediaLinks = true;

            HotelService.BillingPointOfSaleInfo billSaleInfo = new HotelService.BillingPointOfSaleInfo();
            billSaleInfo.OriginApplication = CommonUtility.GetConfigValue(ProjectConstants.APP);

            detailsRequest.BillingPointOfSaleInfo = billSaleInfo;
            detailsRequest.HotelProperty = cheapest.HotelProperty[0];// Cheapsest hotel selected

            HotelService.HotelDetailsModifiers hotelDetailsModifiers = new HotelService.HotelDetailsModifiers();
            hotelDetailsModifiers.HotelStay = GetHotelStay();
            hotelDetailsModifiers.NumberOfAdults = numberOfAdults;
            hotelDetailsModifiers.NumberOfRooms = numberOfRooms;
            hotelDetailsModifiers.RateRuleDetail = HotelService.typeRateRuleDetail.Complete;
            hotelDetailsModifiers.PermittedProviders = new HotelService.PermittedProviders()
            {
                Provider = new HotelService.Provider()
                {
                    Code = providerCode
                }
            };

            detailsRequest.HotelDetailsModifiers = hotelDetailsModifiers;


            HotelDetailsServicePortTypeClient detailsClient = new HotelDetailsServicePortTypeClient("HotelDetailsServicePort", WsdlService.HOTEL_ENDPOINT);            
            detailsClient.ClientCredentials.UserName.UserName = Helper.RetrunUsername();
            detailsClient.ClientCredentials.UserName.Password = Helper.ReturnPassword();

            try
            {
                var httpHeaders = Helper.ReturnHttpHeader();
                detailsClient.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders));

                detailsResponse = detailsClient.service(detailsRequest);                
            }
            catch (Exception se)
            {
                Console.WriteLine("Error : " + se.Message);
                detailsClient.Abort();
            }


            return detailsResponse;
        }
Esempio n. 10
0
        private async void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            if (cancellationTokenSource != null)
            {
                SearchButton.IsEnabled = false;
                cancellationTokenSource.Cancel();
                return;
            }
            Stopwatch sw = Stopwatch.StartNew();

            cancellationTokenSource = new CancellationTokenSource();
            SearchButton.Content    = "Terminate";
            //
            string hotelName = HotelNameTextBox.Text;

            Hotel[]           hotelEntities;
            HotelSearchResult hotelSearchResult = null;

            using (HotelDBEntitiesConn context = new HotelDBEntitiesConn())
            {
                hotelEntities = await context.Hotels.Where(x => x.Name == hotelName).ToArrayAsync(cancellationTokenSource.Token);
            }
            if (hotelEntities.Length > 0)
            {
                hotelSearchResult = new HotelSearchResult
                {
                    SearchName = hotelName
                };
                foreach (Hotel hotelEntity in hotelEntities)
                {
                    HotelData hotelData = JsonConvert.DeserializeObject <HotelData>(hotelEntity.Data);
                    hotelSearchResult.Hotels.Add(hotelData);
                }
            }
            else
            {
                HotelDataCrawler.HotelDataCrawler crawler = new HotelDataCrawler.HotelDataCrawler();
                try
                {
                    hotelSearchResult = await crawler.SearchHotels(hotelName, cancellationTokenSource.Token);

                    using (HotelDBEntitiesConn context = new HotelDBEntitiesConn())
                    {
                        foreach (HotelData hotelData in hotelSearchResult.Hotels)
                        {
                            Hotel hotelEntity = new Hotel
                            {
                                Name    = (string)hotelData.GetParameterValue(HotelParameterType.Name),
                                WebSite = (int)hotelData.WebSite,
                                Data    = JsonConvert.SerializeObject(hotelData, new JsonSerializerSettings
                                {
                                    NullValueHandling = NullValueHandling.Ignore
                                })
                            };
                            context.Hotels.Add(hotelEntity);
                        }
                        await context.SaveChangesAsync(cancellationTokenSource.Token);
                    }
                }
                catch (TaskCanceledException)
                {
                    // ignore
                }
            }
            StringBuilder sb = new StringBuilder();

            sb.Append(cancellationTokenSource.IsCancellationRequested ? "Terminated" : "Finished")
            .Append(" in ").Append(sw.Elapsed).AppendLine();
            if (hotelSearchResult != null)
            {
                sb.Append(JsonConvert.SerializeObject(hotelSearchResult, Formatting.Indented, new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore
                }));
            }

            LogTextBox.Text         = sb.ToString();
            SearchButton.Content    = "Search";
            SearchButton.IsEnabled  = true;
            cancellationTokenSource = null;
        }
Esempio n. 11
0
        public List <HotelSearchResult> MapSearchResult(List <SearchOutputData> searchOutputs, List <BoardCode> boardCodes, SearchData searchData)
        {
            try
            {
                //save result
                //apply salesRules
                CurrencyManager   currencyManager           = new CurrencyManager();
                SalesRulesManager ServiceChargeManager      = new SalesRulesManager();
                SalesRulesManager CancellationChargeManager = new SalesRulesManager();

                //start sales rules service charge
                ServiceChargeManager.FillSalesRules(searchData.POS, "Hotel", "Service Charge");
                ServiceChargeManager.PrepareSearchCriteriaDic(searchData);
                ////
                /////cancellation charge
                CancellationChargeManager.FillSalesRules(searchData.POS, "Hotel", "Cancellation Charge");
                CancellationChargeManager.PrepareSearchCriteriaDic(searchData);
                //

                List <string>            hotelIds      = searchOutputs.Select(a => a.hotelCode).ToList();
                HotelManager             manager       = new HotelManager();
                List <HotelDetails>      HotelDataList = manager.GetHotelData(hotelIds, "3");
                List <HotelSearchResult> results       = new List <HotelSearchResult>();
                var BaseCur = ConfigurationSettings.AppSettings["BaseCur"];
                // Provider Exchange Rate From User Curency To Provider Curency
                double ProviderExcahngeRate = currencyManager.GetCurrencyConversion(searchData.Currency, BaseCur, searchData.sID);
                /////double ProviderExcahngeRate = currencyManager.GetCurrencyConversion("EUR", BaseCur);
                // Exchange Rate From Base Curency to user cur
                double ExcahngeRate = currencyManager.GetCurrencyConversion(BaseCur, searchData.Currency, searchData.sID);
                int    duration     = Convert.ToInt32((searchData.DateTo - searchData.DateFrom).TotalDays);
                {
                    DateTime CheckInDate = searchData.DateFrom;
                    for (int i = 0; i < searchOutputs.Count; i++)
                    {
                        BoardCode         boardCode = boardCodes.Where(a => a.Code == searchOutputs[i].boardCode).FirstOrDefault();
                        HotelDetails      hotelData = HotelDataList.Where(a => a.ProviderHotelId == searchOutputs[i].hotelCode).FirstOrDefault();
                        HotelSearchResult hotel     = new HotelSearchResult();
                        hotel.hotelCode  = searchOutputs[i].hotelCode;
                        hotel.City       = hotelData.City;
                        hotel.hotelName  = hotelData.HotelName;
                        hotel.Country    = hotelData.Country;
                        hotel.hotelStars = int.Parse(hotelData.Rating) - 558;
                        var images = hotelData.Images.FirstOrDefault();
                        if (images != null)
                        {
                            hotel.hotelThumb = images.Thum;
                        }
                        hotel.hotelImages              = hotelData.Images.Select(a => a.Thum).ToList();
                        hotel.Lat                      = hotelData.Lat;
                        hotel.Lng                      = hotelData.Lng;
                        hotel.providerID               = "3";
                        hotel.hotelDescription         = hotelData.LongDescriptin;
                        hotel.shortcutHotelDescription = hotelData.ShortDescription;
                        hotel.ZipCode                  = hotelData.Zipcode;
                        hotel.Location                 = hotelData.Location;
                        hotel.Address                  = hotelData.Address;
                        hotel.providerHotelID          = hotelData.ProviderHotelId;
                        hotel.providerHotelCode        = hotelData.HotelId;
                        hotel.sellCurrency             = searchData.Currency;
                        //  hotel.costPrice =//Math.Round( (double.Parse(searchOutputs[i].price.net.Value.ToString()) * ProviderExcahngeRate) /duration,3);
                        hotel.costCurrency = searchOutputs[i].price.currency;
                        //set sales rules cirtiera



                        //  hotel.hotelRate = ((hotel.costPrice)+ AppliedMarkup.Value-AppliedDiscount.Value)* ExcahngeRate;

                        hotel.rooms = new List <RoomResult>();
                        CancellationChargeManager.SetResultCriteria(hotel.hotelName, hotel.hotelStars, hotel.costPrice, "3");
                        AppliedSalesRule AppliedCancellationMarkup = CancellationChargeManager.ApplySalesRules("Markup");

                        for (int j = 0; j < searchOutputs[i].rooms.Count; j++)
                        {
                            RoomResult room = new RoomResult();
                            room.CostPrice = Math.Round(double.Parse(searchOutputs[i].rooms[j].roomPrice.price.net.Value.ToString()), 3);

                            ServiceChargeManager.SetResultCriteria(hotel.hotelName, hotel.hotelStars, room.CostPrice
                                                                   * ProviderExcahngeRate, "3");
                            AppliedSalesRule AppliedMarkup   = ServiceChargeManager.ApplySalesRules("Markup");
                            AppliedSalesRule AppliedDiscount = ServiceChargeManager.ApplySalesRules("Discount");

                            room.IsRefundable   = searchOutputs[i].rooms[j].refundable;
                            room.RatePerNight   = ((double.Parse(searchOutputs[i].rooms[j].roomPrice.price.net.Value.ToString()) * ProviderExcahngeRate / duration) + AppliedMarkup.Value - AppliedDiscount.Value) * ExcahngeRate;
                            room.TotalSellPrice = Math.Round(room.RatePerNight * duration, 3);
                            room.RoomIndex      = j + 1;
                            room.RoomReference  = searchOutputs[i].id;

                            room.RoomType          = searchOutputs[i].rooms[j].description;
                            room.RoomMeal          = boardCode.Name;
                            room.Images            = hotelData.Images.Where(a => a.Category.ToLower() == "hotel rooms").Select(a => a.Thum).ToList();
                            room.DiscountId        = AppliedDiscount.ID;
                            room.MarkupId          = AppliedMarkup.ID;
                            room.DiscountValue     = AppliedDiscount.Value * ExcahngeRate;
                            room.MarkupValue       = AppliedMarkup.Value * ExcahngeRate;
                            room.cancellationRules = searchOutputs[i].cancelPolicy.cancelPenalties == null? new List <CancellationRule>()
                            {
                                new CancellationRule {
                                    Cost = Math.Round((AppliedCancellationMarkup.Value) * ExcahngeRate, 3)
                                }
                            } :
                            searchOutputs[i].cancelPolicy.cancelPenalties.Select(a => new CancellationRule
                            {
                                ToDate = CheckInDate.AddHours(-a.hoursBefore.Value).ToString("dd MMM yyyy"),
                                Cost   = Math.Round(((a.value.Value * ProviderExcahngeRate) + AppliedCancellationMarkup.Value) * ExcahngeRate, 3),
                                CanellationRuleText = searchData.Lang.ToLower() == "en"? Math.Round(((a.value.Value * ProviderExcahngeRate) + AppliedCancellationMarkup.Value) * ExcahngeRate, 3) + "" + searchData.Currency + " To " + CheckInDate.AddHours(-a.hoursBefore.Value).ToString("dd MMM yyyy") : CheckInDate.AddHours(-a.hoursBefore.Value).ToString("dd MMM yyyy") + " إلى " + "" + searchData.Currency + Math.Round(((a.value.Value * ProviderExcahngeRate) + AppliedCancellationMarkup.Value) * ExcahngeRate, 3)
                            }).ToList();
                            hotel.rooms.Add(room);
                        }
                        var minRoom = hotel.rooms.Where(a => a.RatePerNight == hotel.rooms.Min(x => x.RatePerNight)).FirstOrDefault();
                        hotel.hotelRate      = minRoom.RatePerNight;
                        hotel.costPrice      = minRoom.CostPrice;
                        hotel.TotalSellPrice = minRoom.TotalSellPrice;
                        hotel.MarkupId       = minRoom.MarkupId;
                        hotel.MarkupValue    = minRoom.MarkupValue;
                        hotel.DiscountId     = minRoom.DiscountId;
                        hotel.DiscountValue  = minRoom.DiscountValue;
                        results.Add(hotel);
                    }
                    return(results);
                }
            }
            catch (Exception ex) {
                LoggingHelper.WriteToFile("MapSearchResult/Errors/", "MapSearchResult_" + searchData.sID, ex.InnerException?.Message, ex.Message + " Sourse :" + ex.Source + " Stack Trace :" + ex.StackTrace);
                return(new List <HotelSearchResult>());
            }
        }