Example #1
0
        /*------------------------------------------------END OF Deleting the City------------------------------------------------*/
        // CRUD on Hotel Table
        //Adding Hotel in the hotelDetails Table
        public bool AddHotel(CityHotelDetailsFromAdmin hotel)
        {
            CityDetails cityDetails = new CityDetails();

            cityDetails.cityName = hotel.cityName;


            HotelDetails hotelDetails = new HotelDetails();

            hotelDetails.hotelName    = hotel.hotelName;
            hotelDetails.hotelAddress = hotel.hotelAddress;
            hotelDetails.doubleRooms  = hotel.numberOfDoubleRooms;
            hotelDetails.starRating   = hotel.hotelRating;
            hotelDetails.singleRooms  = hotel.numberOfSingleRooms;

            RoomDetails roomDetails = new RoomDetails();

            if (CheckCityIfExists(cityDetails.cityName))
            {
                if (!AddCity(cityDetails))
                {
                    return(false);
                }
            }
            int cityId = dbContext.cityDetails.Where(y => y.cityName == cityDetails.cityName).Select(y => y.cityId).FirstOrDefault();

            if (CheckHotelIfExists(hotelDetails.hotelName, cityId))
            {
                dbContext.hotelDetails.Add(hotelDetails);
                dbContext.SaveChanges();
                int hotelId = FindTheAppropriateHotelId(hotel.hotelName);
                //Calling a different function to map Hotel and City Id
                if (!CityIdHotelIdUpdate(cityId, hotelId))
                {
                    return(false);
                }

                //Starting to add rooms
                for (int i = 1; i <= hotel.numberOfSingleRooms; i++)
                {
                    roomDetails.hotelId  = hotelId;
                    roomDetails.roomType = "Single";
                    roomDetails.price    = hotel.priceOfSingleRoom;

                    if (!AddRoom(roomDetails))
                    {
                        return(false);
                    }
                }
                for (int i = 1; i <= hotel.numberOfDoubleRooms; i++)
                {
                    roomDetails.hotelId  = hotelId;
                    roomDetails.roomType = "Double";
                    roomDetails.price    = hotel.priceOfDoubleRoom;

                    if (!AddRoom(roomDetails))
                    {
                        return(false);
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
        // 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());
            }
        }
        public List <HotelChannelResult> MapSearchResult(List <Hotel> searchOutputs, SearchData searchData)
        {
            try
            {
                //save result
                //apply salesRules
                List <HotelChannelResult> searchResponse            = new List <HotelChannelResult>();
                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.GetChannelHotelData(hotelIds, "4");
                //  List<HotelSearchResult> results = new List<HotelSearchResult>();
                double ProviderExcahngeRate = currencyManager.GetCurrencyConversion(searchOutputs[0].currency, BaseCur, searchData.sID);
                /////double ProviderExcahngeRate = currencyManager.GetCurrencyConversion("EUR", BaseCur);
                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();
                        HotelChannelResult hotel     = new HotelChannelResult();
                        if (hotelData != null)
                        {
                            hotel.providerHotelCode = searchOutputs[i].code.ToString();
                            hotel.providerID        = "4";

                            hotel.providerHotelID = hotelData.ProviderHotelId;
                            hotel.hotelId         = hotelData.ID.ToString();
                            hotel.sellCurrency    = searchData.Currency;
                            //  hotel.costPrice =//Math.Round( (double.Parse(searchOutputs[i].price.net.Value.ToString()) * ProviderExcahngeRate) /duration,3);
                            hotel.costCurrency = searchOutputs[i].currency;
                            hotel.DeepLink     = "http://93.115.27.156:3030/api/WegoHotelSearch?sid=" + searchData.sID + "&hotelId=" + hotelData.HotelId + "&pid=4";
                            CancellationChargeManager.SetResultCriteria(hotelData.HotelName, int.Parse(hotelData.Rating), hotel.costPrice, "4");
                            AppliedSalesRule AppliedCancellationMarkup = CancellationChargeManager.ApplySalesRules("Markup");
                            int roomcount    = 0;
                            int Packagecount = 0;

                            for (int j = 0; j < searchOutputs[i].rooms.Count; j++)
                            {
                                if (Packagecount == 20)
                                {
                                }
                                RoomPackages            roomPackage = new RoomPackages();
                                List <ChannelRoomsRate> roomsRate   = new List <ChannelRoomsRate>();
                                roomPackage.RoomCategory = searchOutputs[i].rooms[j].name;
                                List <RoomPackage> Containers = new List <RoomPackage>();
                                for (int r = 0; r < searchData.SearchRooms.Count; r++)
                                {
                                    ChannelRoomsRate roomRate = new ChannelRoomsRate();

                                    /*  var rooms = searchOutputs[i].rooms[j].rates.GroupBy(c => new
                                     * {
                                     *    c.adults,
                                     *    c.children,
                                     * }).Select(c => c.Where(a=>a.adults== searchData.SearchRooms[r].Adult &&a.children== searchData.SearchRooms[r].Child.Count).ToList());
                                     */
                                    var rooms = searchOutputs[i].rooms[j].rates.Where(a => a.adults == searchData.SearchRooms[r].Adult && a.children == searchData.SearchRooms[r].Child.Count).GroupBy(p => p.rateKey).Select(grp => grp.FirstOrDefault()).ToList();
                                    if (rooms.Count > 0)
                                    {
                                        roomRate.RoomRates.AddRange(rooms);
                                        roomsRate.Add(roomRate);
                                    }
                                    else
                                    {
                                        var roomnames = searchOutputs[i].rooms[j].name.Split(' ');
                                        //    var key = roomnames[roomnames.Length-1];
                                        int indexToRemove = 0;
                                        roomnames = roomnames.Where((source, index) => index != indexToRemove).ToArray();
                                        var key       = string.Join(" ", roomnames);
                                        var roomstype = searchOutputs[i].rooms.Where(a => a.name.Contains(key));
                                        foreach (var item in roomstype)
                                        {
                                            var lstroom        = item.name.Split(' ');
                                            int index1ToRemove = 0;
                                            lstroom = lstroom.Where((source, index) => index != index1ToRemove).ToArray();
                                            var key1 = string.Join(" ", lstroom);
                                            if (key == key1)
                                            {
                                                var RoomsSameType = item.rates.Where(a => a.adults == searchData.SearchRooms[r].Adult && a.children == searchData.SearchRooms[r].Child.Count).GroupBy(p => p.rateKey).Select(grp => grp.FirstOrDefault()).ToList();
                                                if (RoomsSameType.Count > 0)
                                                {
                                                    roomRate.RoomRates.AddRange(RoomsSameType);
                                                    roomsRate.Add(roomRate);
                                                }
                                            }
                                        }
                                    }
                                    if (roomRate.RoomRates.Count == 0)
                                    {
                                        roomsRate = new List <ChannelRoomsRate>();
                                        break;
                                    }
                                }
                                int max = 0;
                                if (roomsRate.Count > 0)
                                {
                                    max = roomsRate.Max(r => r.RoomRates.Count);
                                }

                                for (int ra = 0; ra < max; ra++)
                                {
                                    RoomPackage Container    = new RoomPackage();
                                    double      sellPerNight = 0;
                                    double      sellPerAll   = 0;

                                    List <RoomResult> resultsPackage = new List <RoomResult>();
                                    foreach (var item in roomsRate)
                                    {
                                        int indx = ra;
                                        if (ra >= item.RoomRates.Count)
                                        {
                                            indx = item.RoomRates.Count - 1;
                                        }
                                        RoomResult room = new RoomResult();

                                        room.PackageNO = Packagecount + 1;
                                        if (item.RoomRates[indx].net == null)
                                        {
                                            continue;
                                        }
                                        room.CostPrice = Math.Round(double.Parse(item.RoomRates[indx].net), 3);

                                        ServiceChargeManager.SetResultCriteria(hotelData.HotelName, int.Parse(hotelData.Rating), 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);
                                        sellPerNight       += room.RatePerNight;
                                        room.TotalSellPrice = Math.Round(room.RatePerNight * duration, 3);
                                        sellPerAll         += room.TotalSellPrice;
                                        roomcount          += 1;
                                        room.RoomIndex      = roomcount;
                                        room.RoomReference  = item.RoomRates[indx].rateKey;
                                        /////
                                        room.RoomCode = searchOutputs[i].rooms[j].code;
                                        /////////
                                        room.RoomType = searchOutputs[i].rooms[j].name;
                                        ///////
                                        room.RoomMeal     = item.RoomRates[indx].boardName;
                                        room.Adult        = item.RoomRates[indx].adults;
                                        room.Child        = item.RoomRates[indx].children;
                                        room.IsRefundable = item.RoomRates[indx].rateClass == "NRF" ? false : true;

                                        ///////
                                        room.Paxs = item.RoomRates[indx].adults + item.RoomRates[indx].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.cancellationRules = item.RoomRates[indx].cancellationPolicies == null ? new List <CancellationRule>()
                                        {
                                            new CancellationRule {
                                                Cost = 0, Price = 0, CanellationRuleText = null, FromDate = null, ToDate = null
                                            }
                                        } :
                                        item.RoomRates[indx].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();
                                        resultsPackage.Add(room);
                                    }
                                    Container.No               = Packagecount + 1;
                                    Container.PricePerNight    = sellPerNight;
                                    Container.PricePerAllNight = sellPerAll;
                                    Container.roomResults.AddRange(resultsPackage);
                                    Containers.Add(Container);
                                    Packagecount += 1;
                                }
                                roomPackage.roomPackages.AddRange(Containers);
                                hotel.packages.Add(roomPackage);
                            }
                            double MinPerNight = 0;
                            double MinperAll   = 0;
                            var    mindata     = hotel.packages[0].roomPackages.Where(a => a.PricePerAllNight == hotel.packages[0].roomPackages.Min(x => x.PricePerAllNight)).FirstOrDefault();
                            if (mindata != null)
                            {
                                MinperAll   = mindata.PricePerAllNight;
                                MinPerNight = mindata.PricePerNight;
                            }
                            foreach (var item in hotel.packages)
                            {
                                var minPackage = item.roomPackages.Where(a => a.PricePerAllNight == item.roomPackages.Min(x => x.PricePerAllNight)).FirstOrDefault();
                                if (minPackage != null)
                                {
                                    if (minPackage.PricePerAllNight < MinperAll)
                                    {
                                        MinperAll   = minPackage.PricePerAllNight;
                                        MinPerNight = minPackage.PricePerNight;
                                    }
                                }
                            }
                            // var minRoom = hotel.rooms.Where(a => a.RatePerNight == hotel.rooms.Min(x => x.RatePerNight)).FirstOrDefault();
                            if (MinperAll > 0)
                            {
                                hotel.PricePerNight = MinPerNight;
                                //   hotel.costPrice = minRoom.CostPrice;
                                hotel.PricePerAllNight = MinperAll;
                            }
                            searchResponse.Add(hotel);
                        }
                    }
                    //  searchResponse.HotelResult = results;
                    return(searchResponse);
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.WriteToFile("MapSearchResultChannel/Errors/", "MapSearchResult_" + searchData.sID, ex.Message, ex.Message + " Sourse :" + ex.Source + " Stack Trace :" + ex.StackTrace);
                return(new List <HotelChannelResult>());
            }
        }
Example #4
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());
            }
        }
Example #5
0
        public ActionResult Gethoteldetails()
        {
            HotelDetails hd = new HotelDetails();

            return(View(hd));
        }
        public IActionResult Index(int idHotel, int destination)
        {
            HotelDetails hotel = new HotelDetails().GetHotelDetails(destination, idHotel);

            return(View(hotel));
        }
Example #7
0
        public List <HotelDetails> GetHotelData(List <string> HotelProvidersIds, string providerId)
        {
            try
            {
                DataTable           dh       = new DataTable();
                List <Image>        images   = new List <Image>();
                List <HotelAmenity> amenties = new List <HotelAmenity>();
                List <HotelDetails> list     = new List <HotelDetails>();
                DataColumn          hCode    = new DataColumn("PHotelId");
                dh.Columns.Add(hCode);
                foreach (var item in HotelProvidersIds)
                {
                    DataRow DtH = dh.NewRow();
                    // Model.Hotel hotel = new Model.Hotel();
                    DtH["PHotelId"] = item;
                    dh.Rows.Add(DtH);
                }
                var           connStr = ConfigurationSettings.AppSettings["HDB_CS"];
                SqlConnection conn    = new SqlConnection(connStr);
                conn.Open();
                SqlCommand cmd = new SqlCommand("GetHotelsImagesforSearch", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("providerHotelsID", dh));
                // need to pass providerId instead of "4"
                cmd.Parameters.Add(new SqlParameter("PID", "4"));
                SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

                while (dr.Read())
                {
                    Image img = new Image();
                    img.Category = dr["Category"].ToString();
                    img.HotelId  = dr["HotelID"].ToString();
                    img.Thum     = dr["Thum"].ToString();
                    img.Url      = dr["URL"].ToString();
                    images.Add(img);
                }
                dr.Close();
                conn.Close();
                conn.Open();

                /*     SqlCommand cmd2 = new SqlCommand("GetHotelsAmenityforSearch", conn);
                 *   cmd2.CommandType = CommandType.StoredProcedure;
                 *   cmd2.Parameters.Add(new SqlParameter("providerHotelsID", dh));
                 *   cmd2.Parameters.Add(new SqlParameter("PID", "4"));
                 *   SqlDataReader dr2 = cmd2.ExecuteReader(CommandBehavior.CloseConnection);
                 *
                 *   while (dr2.Read())
                 *   {
                 *       HotelAmenity AM = new HotelAmenity();
                 *       AM.Amenity = dr2["amenitie"].ToString();
                 *       AM.HotelCode = dr2["hotelID"].ToString();
                 *       AM.status = dr2["Status"].ToString();
                 *       amenties.Add(AM);
                 *
                 *   }*/
                //close DataReader
                //  dr2.Close();
                conn.Close();
                conn.Open();
                SqlCommand cmd3 = new SqlCommand("GetHotelsDataforSearch", conn);
                cmd3.CommandType = CommandType.StoredProcedure;
                cmd3.Parameters.Add(new SqlParameter("providerHotelsID", dh));
                cmd3.Parameters.Add(new SqlParameter("PID", "4"));
                SqlDataReader dr3 = cmd3.ExecuteReader(CommandBehavior.CloseConnection);

                while (dr3.Read())
                {
                    HotelDetails hotel = new HotelDetails();
                    hotel.Address          = dr3["address"].ToString();
                    hotel.City             = dr3["cityName"].ToString();
                    hotel.Country          = dr3["countryName"].ToString();
                    hotel.HotelId          = dr3["hotelID"].ToString();
                    hotel.HotelName        = dr3["hotelName"].ToString();
                    hotel.ID               = int.Parse(dr3["ID"].ToString());
                    hotel.Lat              = dr3["Lat"].ToString();
                    hotel.Lng              = dr3["Lng"].ToString();
                    hotel.Location         = dr3["location"].ToString();
                    hotel.LongDescriptin   = dr3["Description1"].ToString();
                    hotel.ProviderHotelId  = dr3["providerHotelID"].ToString();
                    hotel.ProviderID       = dr3["providerID"].ToString();
                    hotel.Rating           = dr3["rating"].ToString();
                    hotel.ShortDescription = dr3["Description2"].ToString();
                    hotel.Zipcode          = dr3["zipCode"].ToString();

                    list.Add(hotel);
                }
                //close DataReader
                dr3.Close();
                conn.Close();
                // using (hotelsDBEntities db = new hotelsDBEntities())
                //  {

                /*  List<Image> images = (from h in db.hotels
                 *                        join p in db.hotelsProviders on h.ID.ToString() equals p.hotelID
                 *                        join i in db.HotelsImages on h.hotelID equals i.HotelID
                 *                        where HotelProvidersIds.Contains(p.providerHotelID.ToString()) && p.providerID == providerId
                 *                        select new Image()
                 *                        {
                 *                            Thum = i.Thum,
                 *                            HotelId = h.hotelID,
                 *                            Category = i.Category,
                 *                            Url = i.URL
                 *
                 *                        }).ToList();*/

                /*    List<HotelAmenity> amenties = (from h in db.hotels
                 *                                 join p in db.hotelsProviders on h.ID.ToString() equals p.hotelID
                 *                                 join A in db.HotelsAmenities on h.hotelID equals A.hotelID
                 *                                 where HotelProvidersIds.Contains(p.providerHotelID.ToString()) && p.providerID == providerId
                 *                                 select new HotelAmenity()
                 *                                 {
                 *                                     Amenity = A.amenitie,
                 *                                     HotelCode = h.hotelID,
                 *                                     status = A.Status
                 *                                 }).ToList();*/

                /*  list = (from h in db.hotels
                 *        join p in db.hotelsProviders on h.ID.ToString() equals p.hotelID
                 *        join d in db.HotelsDescriptions on h.hotelID equals d.hotelID
                 *        where HotelProvidersIds.Contains(p.providerHotelID.ToString()) && p.providerID == providerId
                 *        select new HotelDetails()
                 *        {
                 *            ID = h.ID,
                 *            HotelId = h.hotelID,
                 *            Address = h.address,
                 *            Rating = h.rating,
                 *            HotelName = h.hotelName,
                 *            Zipcode = h.zipCode,
                 *            ProviderHotelId = p.providerHotelID,
                 *            ProviderID = p.providerID,
                 *            Location = h.location,
                 *            ShortDescription = d.Description2,
                 *            LongDescriptin = d.Description1,
                 *            City = h.cityName,
                 *            Country = h.countryName,
                 *            Lat = h.Lat,
                 *            Lng = h.Lng,
                 *            Location1 = h.location1,Location2=h.location2,Location3=h.location3
                 *
                 *
                 *            //{ 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;
                //    }

                list.ForEach(a => a.Images = images.Where(h => h.HotelId == a.HotelId).ToList());
                return(list);
            }

            catch (Exception ex)
            {
                //log exp
                LoggingHelper.WriteToFile("SearchController/MapSearchResultHB/GetHotelDataFromDB/Errors/", "GetHotelDataFromDB_", ex.Message, ex.Message + " Sourse :" + ex.Source + " Stack Trace :" + ex.StackTrace);

                return(new List <HotelDetails>());
            }

            // }
        }
        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>());
            }
        }
    public static HotelDetails[] GetHotels(String args)
    {
        try
        {
            string[] strValues = args.Split('&');

            List<HotelDetails> details = new List<HotelDetails>();

            IArzooHotelAPILayer objArzooHotelAPILayer = ArzooHotelFactoryManager.GetArzooHotelAPILayerObject();
            objArzooHotelAPILayer.UserName = ArzooHotelConstants.USERNAME;
            objArzooHotelAPILayer.UserId = ArzooHotelConstants.USERID;
            objArzooHotelAPILayer.UserType = ArzooHotelConstants.USERTYPE;
            objArzooHotelAPILayer.Password = ArzooHotelConstants.PASSWORD;
            objArzooHotelAPILayer.PartnerId = ArzooHotelConstants.PARTNERID;

            string startDate = strValues[1].ToString();
            string endDate = strValues[2].ToString();

            int noOfRooms = Convert.ToInt32(strValues[3].ToString());

            int[] noOfAdultsInARoom = new int[noOfRooms];
            int[] noOfChildsInARoom = new int[noOfRooms];
            int[] firstChildAge = new int[noOfRooms];
            int[] secondChildAge = new int[noOfRooms];
            int j = 0;
            for (int i = 0; i < noOfRooms; i++)
            {
                if (i == 0)
                {
                    j = 0;
                }
                else
                {
                    j = 4 * i;
                }

                noOfAdultsInARoom[i] = Convert.ToInt32(strValues[4 + j].ToString());
                noOfChildsInARoom[i] = Convert.ToInt32(strValues[5 + j].ToString());
                firstChildAge[i] = Convert.ToInt32(strValues[6 + j].ToString());
                secondChildAge[i] = Convert.ToInt32(strValues[7 + j].ToString());
            }

            string cityName = strValues[0].ToString();
            string hotelName = "";
            string area = "";
            string rating = "";

            DataSet dsHotelAvailSearch = objArzooHotelAPILayer.GetHotelAvailSearch(ConvertDate1(startDate), ConvertDate1(endDate), noOfRooms,
                noOfAdultsInARoom, noOfChildsInARoom, firstChildAge, secondChildAge, cityName, hotelName, area, rating);

            if (!dsHotelAvailSearch.Tables.Contains("Error"))
            {
                foreach (DataRow item in dsHotelAvailSearch.Tables["Hotels"].Rows)
                {
                    HotelDetails hotel = new HotelDetails();
                    hotel.HotelId = item["hotelid"].ToString();
                    hotel.HotelName = item["hotelname"].ToString();
                    hotel.HotelDescription = item["hoteldesc"].ToString();

                    hotel.HotelChain = item["hotelchain"].ToString();
                    hotel.StarRating = item["starrating"].ToString();
                    hotel.NoOfRooms = item["noofrooms"].ToString();

                    hotel.MinRate = item["minRate"].ToString();
                    hotel.Rph = item["rph"].ToString();
                    hotel.WebService = item["webService"].ToString();

                    hotel.Facilities = item["facilities"].ToString();
                    hotel.hotel_Id = item["hotel_Id"].ToString();
                    hotel.hoteldetail_Id = item["hoteldetail_Id"].ToString();

                    hotel.Address = item["address"].ToString();
                    hotel.PinCode = item["pincode"].ToString();
                    hotel.CityWiseLocation = item["citywiselocation"].ToString();

                    hotel.LocationInfo = item["locationinfo"].ToString();
                    hotel.Phone = item["phone"].ToString();
                    hotel.Fax = item["fax"].ToString();
                    hotel.Email = item["email"].ToString();
                    hotel.Website = item["website"].ToString();

                    hotel.ImageDesc = item["imagedesc"].ToString();
                    hotel.ImagePath = item["imagepath"].ToString();
                    hotel.images_Id = item["images_Id"].ToString();
                    hotel.CheckInTime = item["checkintime"].ToString();

                    hotel.CheckOutTime = item["checkouttime"].ToString();
                    hotel.CreditCards = item["creditcards"].ToString();
                    hotel.HotelServices = item["hotelservices"].ToString();
                    hotel.RoomServices = item["roomservices"].ToString();

                    details.Add(hotel);
                }
            }
            System.Web.HttpContext.Current.Session["Hotels"] = details.ToArray();
            if (details.ToArray().Length > 20)
            {
                return details.GetRange(0, 20).ToArray();
            }
            else { return details.ToArray(); }
        }
        catch (Exception ex)
        {
            throw new ArgumentException(ex.Message);
        }
    }