public List <CityWithCountryName> AllCities( )
        {
            List <CityWithCountryName> cities = new List <CityWithCountryName>();

            using (TBOContext tBOContext = new TBOContext())
            {
                var TBOCities = tBOContext.Cities.Include(ww => ww.Country).AsNoTracking().ToList();
                foreach (var item in TBOCities)
                {
                    cities.Add(new CityWithCountryName
                    {
                        CityId          = int.Parse(item.CityCode),
                        City            = item.CityName,
                        CityWithCountry = item.CityName + "," + item.Country.CountryName,
                        Country         = item.Country.CountryName,
                        CountryCode     = item.Country.CountryCode
                    });
                }
            }



            if (cities.Count == 0)
            {
                return(null);
            }
            return(cities);
        }
Beispiel #2
0
 public List <string> GetHotelIdsByCityCode(string city)
 {
     using (_context = new TBOContext())
     {
         return(_context.HotelDetails.Where(cty => cty.CityCode == city).Select(hot => hot.HotelCode).Take(250).ToList());
     }
 }
Beispiel #3
0
        public RestCriteraiData GetDataForGatewayDA(string BN)
        {
            try
            {
                SearchDBEntities       searchDB       = new SearchDBEntities();
                HotelBookingDBEntities hotelBookingDB = new HotelBookingDBEntities();
                hotelsDBEntities       hotelsDB       = new hotelsDBEntities();
                SearchData             searchData     = new SearchData();
                RestCriteraiData       restCriterai   = new RestCriteraiData();
                var booking = hotelBookingDB.HotelsBookings.FirstOrDefault(x => x.Booking_No == BN);

                var search = searchDB.SearchCriterias.FirstOrDefault(a => a.sID == booking.SessionId);
                restCriterai.searchData          = new SearchData();
                restCriterai.searchData.CityName = search.cityName;
                restCriterai.searchData.Currency = search.currency;
                restCriterai.searchData.DateFrom = search.dateFrom.Value;
                restCriterai.searchData.DateTo   = search.dateTo.Value;
                restCriterai.searchData.Lang     = search.language;
                restCriterai.searchData.Nat      = search.passengerNationality;
                restCriterai.searchData.POS      = search.pos;
                restCriterai.pos               = search.pos;
                restCriterai.searchData.sID    = search.sID;
                restCriterai.searchData.Source = search.source;
                var Rooms = searchDB.SearchRoomDatas.Where(a => a.sID == booking.SessionId).ToList();
                foreach (var item in Rooms)
                {
                    SearchRoom searchRoom = new SearchRoom();
                    searchRoom.Adult = item.adultNo.Value;
                    for (int i = 0; i < item.childernNo.Value; i++)
                    {
                        searchRoom.Child.Add(2);
                    }
                    restCriterai.searchData.SearchRooms.Add(searchRoom);
                }
                // var booking = hotelBookingDB.HotelsBookings.FirstOrDefault(x => x.SessionId == Sid && x.Booking_No == BN);
                restCriterai.cost = booking.Sell_Price.Value;
                restCriterai.Curr = booking.Sell_Currency;
                restCriterai.Pid  = booking.Provider_ID;
                if (restCriterai.Pid == "5")
                {
                    TBOContext bOContext = new TBOContext();
                    var        Hotel     = bOContext.HotelDetails.FirstOrDefault(a => a.HotelCode == booking.Hotel_ID);
                    restCriterai.HotelName = Hotel.HotelName;
                    //restCriterai.HotelStars = int.Parse(Hotel.rating);
                }
                else if (restCriterai.Pid == "4")
                {
                    var Hotel = hotelsDB.hotels.FirstOrDefault(a => a.hotelID == booking.Hotel_ID);
                    restCriterai.HotelName  = Hotel.hotelName;
                    restCriterai.HotelStars = int.Parse(Hotel.rating);
                }

                return(restCriterai);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        public List <CityWithCountryName> GetAllCities(string code)
        {
            List <CityWithCountryName> cities = new List <CityWithCountryName>();

            using (TBOContext tBOContext = new TBOContext())
            {
                var TBOCities = tBOContext.Cities.Where(ww => ww.CityName.Contains(code)).Include(ww => ww.Country).AsNoTracking().ToList();
                foreach (var item in TBOCities)
                {
                    cities.Add(new CityWithCountryName
                    {
                        CityId          = int.Parse(item.CityCode),
                        City            = item.CityName,
                        CityWithCountry = item.CityName + "," + item.Country.CountryName,
                        Country         = item.Country.CountryName
                    });
                }
            }



            //string connString = ConfigurationSettings.AppSettings["hotelsDB"];

            //using (SqlConnection conn = new SqlConnection(connString))
            //{
            //    conn.Open();
            //    SqlCommand cmd = new SqlCommand("GetCitiesForHotels", conn);
            //    // 2. set the command object so it knows to execute a stored procedure
            //    cmd.CommandType = CommandType.StoredProcedure;
            //    cmd.Parameters.Add(new SqlParameter("code", code));



            //    // execute the command
            //    using (SqlDataReader rdr = cmd.ExecuteReader())
            //    {
            //        // iterate through results, printing each to console
            //        while (rdr.Read())
            //        {
            //            CityWithCountryName cityWithCountry = new CityWithCountryName();
            //            cityWithCountry.CityId = int.Parse(rdr["id"].ToString());
            //            //city.City1+" , "+city.countryName
            //            cityWithCountry.CityWithCountry = rdr["city"].ToString() + "," + rdr["countryName"].ToString();
            //            cityWithCountry.City = rdr["city"].ToString();
            //            cityWithCountry.Country = rdr["countryName"].ToString();
            //            cities.Add(cityWithCountry);
            //        }
            //    }
            //}
            if (cities.Count == 0)
            {
                return(null);
            }
            return(cities);
        }
Beispiel #5
0
        public List <HotelAmenity> GetHotelAmenities(string hotelId)
        {
            try
            {
                //need to pass provider Id
                //hotelsDBEntities hotelsDB = new hotelsDBEntities();
                TBOContext          tBOContext    = new TBOContext();
                List <HotelAmenity> amentiesHotel = new List <HotelAmenity>();
                //List<HotelAmenity> amenties = (from A in hotelsDB.HotelsAmenities
                //                               where A.hotelID == hotelId
                //                               select new HotelAmenity()
                //                               {
                //                                   Amenity = A.amenitie,
                //                                   HotelCode = A.hotelID,
                //                                   status = A.Status
                //                               }).ToList();
                List <HotelAmenity> amenties = (from A in tBOContext.Facilities
                                                where A.HotelCode == hotelId
                                                select new HotelAmenity()
                {
                    Amenity = A.FacilityVal,
                    HotelCode = A.HotelCode,
                }).ToList();
                var hotelAmenities = amenties.Where(a => a.HotelCode == hotelId).Distinct().ToList();
                foreach (var am in hotelAmenities)
                {
                    am.Amenity = am.Amenity.Replace("  ", String.Empty);
                    if (amentiesHotel.FirstOrDefault(x => x.Amenity == am.Amenity) == null)
                    {
                        amentiesHotel.Add(am);
                    }
                }
                return(amentiesHotel);
            }
            catch (Exception ex)
            {
                LoggingHelper.WriteToFile("SearchController/Errors/", "GetHotelAmenities" + "INController" + hotelId, ex.InnerException?.Message, ex.Message + ex.StackTrace);

                return(new List <HotelAmenity>());
            }
        }
Beispiel #6
0
        public List <HotelDetails> GetHotelDetails(List <string> HotelProviderIds)
        {
            List <TBO.DAL.Models.HotelDetail> TBODetails = new List <TBO.DAL.Models.HotelDetail>();

            using (_context = new TBOContext())
            {
                foreach (var Id in HotelProviderIds)
                {
                    var HotelDet = _context.HotelDetails.Where(d => d.HotelCode == Id).FirstOrDefault();
                    TBODetails.Add(HotelDet);
                }
            }

            // map TBO DB Table HotelDetails to general
            List <HotelDetails> hotelDetails = new List <HotelDetails>();

            foreach (var det in TBODetails)
            {
                Enum.TryParse(det.HotelRating, out HotelStars stars);
                HotelDetails hotel = new HotelDetails
                {
                    Address          = det.Address,
                    City             = det.CityName,
                    Country          = det.CountryName,
                    HotelId          = det.HotelCode,
                    ProviderHotelId  = det.HotelCode,
                    HotelName        = det.HotelName,
                    Lat              = det.Map,
                    Location         = det.HotelLocation,
                    LongDescriptin   = det.Description,
                    Zipcode          = det.PinCode,
                    Rating           = ((int)stars + 1).ToString(),
                    ShortDescription = det.Attraction,
                    //hotelAmenities=
                    //Images=
                };
                hotelDetails.Add(hotel);
            }

            return(hotelDetails);
        }
        public List <Country> GetAllCounty()
        {
            List <Country> countries = new List <Country>();

            using (TBOContext tBOContext = new TBOContext())
            {
                var res = tBOContext.Countries.AsNoTracking().ToList();
                foreach (var item in res)
                {
                    countries.Add(new Country
                    {
                        code = item.CountryCode,
                        name = item.CountryName,
                        ID   = item.CountryId
                    });
                }
            }
            if (countries.Count == 0)
            {
                return(null);
            }
            return(countries);

            #region HB
            //List<Country> countries = new List<Country>();
            //string connString = ConfigurationSettings.AppSettings["hotelsDB"];

            //using (SqlConnection conn = new SqlConnection(connString))
            //{
            //    conn.Open();
            //    SqlCommand cmd = new SqlCommand("GetCountriesForHotels", conn);

            //    // 2. set the command object so it knows to execute a stored procedure
            //    cmd.CommandType = CommandType.StoredProcedure;



            //    // execute the command
            //    using (SqlDataReader rdr = cmd.ExecuteReader())
            //    {
            //        // iterate through results, printing each to console
            //        while (rdr.Read())
            //        {
            //            Country country = new Country();
            //            country.code = rdr["code"].ToString();
            //            //city.City1+" , "+city.countryName
            //            country.name = rdr["name"].ToString();
            //            country.phoneCode = rdr["phoneCode"].ToString();
            //            country.ID = int.Parse(rdr["ID"].ToString());
            //            country.region = rdr["region"].ToString();
            //            country.regionCode = rdr["regionCode"].ToString();
            //            countries.Add(country);
            //        }
            //    }
            //}
            //if (countries.Count == 0)
            //{
            //    return null;
            //}
            //return countries;
            #endregion
        }
        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);
            }
        }
        public static RequiredBookingData GetRoomsData(string sid, string hotel, string Pid, string rooms)
        {
            try
            {
                SearchDBEntities searchDB = new SearchDBEntities();

                RequiredBookingData requiredBooking = new RequiredBookingData();
                var data   = searchDB.SearchCriterias.FirstOrDefault(a => a.sID == sid);
                var HRooms = searchDB.SearchRoomResults.Where(a => a.sID == sid && a.HotelCode == hotel && a.ProviderId.ToString() == Pid).ToList();
                requiredBooking.Currency = data?.currency;
                requiredBooking.City     = data?.cityName;
                var RoomsCode = rooms.Split('-');
                foreach (var item in RoomsCode)
                {
                    var roomdata = HRooms.FirstOrDefault(a => a.RoomCode == item);

                    requiredBooking.rooms.Add(roomdata);
                }
                if (Pid == "4")
                {
                    hotelsDBEntities hotelsDB = new hotelsDBEntities();
                    var HData   = hotelsDB.hotels.FirstOrDefault(d => d.hotelID == hotel);
                    var HDesc   = hotelsDB.HotelsDescriptions.FirstOrDefault(x => x.hotelID == hotel);
                    var Hsearch = searchDB.SearchHotelResults.FirstOrDefault(x => x.HotelCode == hotel && x.sID == sid && x.ProviderID.ToString() == Pid);
                    var Himage  = hotelsDB.HotelsImages.FirstOrDefault(v => v.HotelID == hotel);
                    requiredBooking.HotelName       = HData?.hotelName;
                    requiredBooking.Hotelstar       = int.Parse(HData?.rating);
                    requiredBooking.address         = HData?.address;
                    requiredBooking.CheckIn         = data?.dateFrom.Value.ToString();
                    requiredBooking.Checkout        = data?.dateTo.Value.ToString();
                    requiredBooking.City            = HData?.cityName;
                    requiredBooking.location        = HData?.location;
                    requiredBooking.HotelDesc       = HDesc?.Description1;
                    requiredBooking.providerHotelID = Hsearch?.ProviderHotelId;
                    requiredBooking.providerID      = Pid;
                    //MG
                    requiredBooking.Lat = HData?.Lat;
                    requiredBooking.Lng = HData?.Lng;
                    if (Himage != null)
                    {
                        requiredBooking.hotelThumb = Himage.Thum;
                    }
                }
                else if (Pid == "5")
                {
                    TBOContext hotelsDB = new TBOContext();
                    var        HData    = hotelsDB.HotelDetails.FirstOrDefault(d => d.HotelCode == hotel);
                    var        Hsearch  = searchDB.SearchHotelResults.FirstOrDefault(x => x.HotelCode == hotel && x.sID == sid && x.ProviderID.ToString() == Pid);
                    var        Himage   = hotelsDB.HotelImages.FirstOrDefault(v => v.HotelCode == hotel);
                    Enum.TryParse(HData.HotelRating, out HotelStars stars);
                    requiredBooking.HotelName       = HData?.HotelName;
                    requiredBooking.Hotelstar       = (int)stars + 1;
                    requiredBooking.address         = HData?.Address;
                    requiredBooking.CheckIn         = data?.dateFrom.Value.ToString();
                    requiredBooking.Checkout        = data?.dateTo.Value.ToString();
                    requiredBooking.City            = HData?.CityName;
                    requiredBooking.location        = HData?.HotelLocation;
                    requiredBooking.HotelDesc       = HData.Description;
                    requiredBooking.providerHotelID = HData?.HotelCode;
                    requiredBooking.providerID      = Pid;
                    //MG
                    requiredBooking.Lat = HData?.HotelLocation;
                    requiredBooking.Lng = HData?.Map;
                    if (Himage != null)
                    {
                        requiredBooking.hotelThumb = Himage.URL;
                    }

                    //instead of call pricing api
                    //RoomResult roomResult = new RoomResult();
                    //using (HotelBookingDBEntities hotelBookingDB = new HotelBookingDBEntities())
                    //{
                    //    foreach (var item in requiredBooking.rooms)
                    //    {
                    //        var cancellations = hotelBookingDB.CancelPolicies.Where(x => x.HotelCode == hotel && x.Sid == sid && x.ProviderID.ToString() == Pid /*&& x.RoomCode ==int.Parse(item.RoomCode)*/).ToList();

                    //        //roomResult.HotelNorms = availRes.HotelCancellationPolicies?.HotelNorms;
                    //        //handel cancel policy
                    //        foreach (var cancel in cancellations)
                    //        {
                    //            CancellationRule cancellation = new CancellationRule();
                    //            //DateTime dateFrom = Convert.ToDateTime(cancel.FromDate);
                    //            cancellation.FromDate = cancel.FromDate.ToString();// dateFrom.ToString("MMMM dd, yyyy");
                    //            cancellation.ToDate = cancel.ToDate.ToString();
                    //            cancellation.Cost = (double)cancel.Cost;
                    //            cancellation.ChargeType = cancel.ChargeType.ToString();
                    //            cancellation.Curency = cancel.Currency;
                    //            roomResult.cancellationRules.Add(cancellation);
                    //        }
                    //    }
                    //    requiredBooking.TBoRooms.Add(roomResult);
                    //}
                }

                return(requiredBooking);


                //   requiredBooking.rooms = searchDB.SearchRoomResults.Where(a => RoomsCode.Contains(a.RoomCode) && a.sID == sid && a.HotelCode == hotel && a.ProviderId.ToString() == Pid).ToList();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #10
0
        public ConfirmationModel GetConfirmationData(string sid, string BN)
        {
            try
            {
                ConfirmationModel       confirmationModel = new ConfirmationModel();
                HotelBookingDBEntities  BookingDB         = new HotelBookingDBEntities();
                SearchDBEntities        searchDB          = new SearchDBEntities();
                hotelsDBEntities        hotelsDB          = new hotelsDBEntities();
                HotelBedEntity          HBDB = new HotelBedEntity();
                List <SearchRoomResult> searchRoomResults = new List <SearchRoomResult>();
                List <SearchRoomResult> SelectedRooms     = new List <SearchRoomResult>();

                var BookingData = BookingDB.HotelsBookings.FirstOrDefault(a => a.SessionId == sid && a.Booking_No == BN);
                var Paxes       = BookingDB.HotelBookingPaxs.Where(x => x.Booking_No == BN && x.SID == sid && x.PaxNo == 1);
                var SearchData  = searchDB.SearchCriterias.FirstOrDefault(a => a.sID == sid);
                var RoomData    = searchDB.SearchRoomDatas.Where(a => a.sID == sid).ToList();
                var Rooms       = Paxes.Select(x => x.RoomRef.ToString()).ToList();
                foreach (var item in Rooms)
                {
                    var roomsearch = searchDB.SearchRoomResults.FirstOrDefault(r => r.sID == sid && r.HotelCode == BookingData.Hotel_ID && r.RoomCode == item);
                    SelectedRooms.Add(roomsearch);
                }
                if (BookingData.Provider_ID == "4")
                {
                    var hotelData = hotelsDB.hotels.FirstOrDefault(a => a.hotelID == BookingData.Hotel_ID);
                    var hotelDesc = hotelsDB.HotelsDescriptions.FirstOrDefault(a => a.hotelID == BookingData.Hotel_ID);
                    confirmationModel.hotel.HotelDescription = hotelDesc.Description1;
                    var hotelsImage = hotelsDB.HotelsImages.Where(a => a.HotelID == BookingData.Hotel_ID).ToList();
                    confirmationModel.hotel.City       = hotelData.cityName;
                    confirmationModel.hotel.Country    = hotelData.countryName;
                    confirmationModel.hotel.hotelCode  = BookingData.Hotel_ID;
                    confirmationModel.hotel.hotelName  = hotelData.hotelName;
                    confirmationModel.hotel.Address    = hotelData.address;
                    confirmationModel.hotel.hotelStars = int.Parse(hotelData.rating);
                    if (hotelsImage.Count > 0)
                    {
                        confirmationModel.hotel.hotelThumb = hotelsImage[0].Thum;
                    }
                    confirmationModel.hotel.Location = hotelData.location;
                }
                else if (BookingData.Provider_ID == "5")
                {
                    using (TBOContext tBOContext = new TBOContext())
                    {
                        var hotelData   = tBOContext.HotelDetails.FirstOrDefault(a => a.HotelCode == BookingData.Hotel_ID);
                        var hotelDesc   = hotelData.Description;
                        var hotelsImage = tBOContext.HotelImages.Where(a => a.HotelCode == BookingData.Hotel_ID).ToList();
                        confirmationModel.hotel.City      = hotelData.CityName;
                        confirmationModel.hotel.Country   = hotelData.CountryName;
                        confirmationModel.hotel.hotelCode = BookingData.Hotel_ID;
                        confirmationModel.hotel.hotelName = hotelData.HotelName;
                        confirmationModel.hotel.Address   = hotelData.Address;
                        //confirmationModel.hotel.hotelStars = int.Parse(hotelData.rating);
                        if (hotelsImage.Count > 0)
                        {
                            confirmationModel.hotel.hotelThumb = hotelsImage[0].URL;
                        }
                        confirmationModel.hotel.Location = hotelData.HotelLocation;
                    }
                }
                confirmationModel.hotel.CheckIn  = SearchData.dateFrom.Value.ToString();
                confirmationModel.BookingTime    = BookingData.Booking_Time.Value;
                confirmationModel.hotel.CheckOut = SearchData.dateTo.Value.ToString();
                confirmationModel.hotel.Paxes    = BookingData.Pax_Qty.Value;
                confirmationModel.hotel.Rooms    = BookingData.Rooms_Qty.Value;
                var PConfirm = BookingDB.BookingConfirmationDatas.FirstOrDefault(a => a.SessionID == sid && a.BookingNum == BN);
                if (PConfirm != null)
                {
                    confirmationModel.ProviderConfirmation = PConfirm.Reference;
                }
                confirmationModel.hotel.sellCurrency   = BookingData.Sell_Currency;
                confirmationModel.hotel.TotalSellPrice = BookingData.Sell_Price.Value;
                confirmationModel.bookingNum           = BookingData.Booking_No;
                confirmationModel.mail   = BookingData.Booking_Email;
                confirmationModel.status = BookingData.Booking_Status;
                CurrencyRepo repo         = new CurrencyRepo();
                double       ExcahngeRate = repo.GetEveryDayCurrenciesConversion(SearchData.currency, BookingData.Sell_Currency, sid, DateTime.Now).Result.Customer_Sell_Rate;
                foreach (var item in Paxes)
                {
                    ConfirmedTraveller traveller = new ConfirmedTraveller();
                    traveller.FirstName = item.First_name;
                    traveller.LastName  = item.Last_Name;
                    traveller.Title     = item.Salutations;
                    var roomResult = SelectedRooms.FirstOrDefault(x => x.RoomCode == item.RoomRef.ToString());
                    searchRoomResults.Add(roomResult);
                    var specRoom1 = SelectedRooms.FirstOrDefault(s => s.RoomCode == item.RoomRef.ToString());
                    if (specRoom1.Childern != 0)
                    {
                        var specRoom = SelectedRooms.FirstOrDefault(s => s.RoomCode == item.RoomRef.ToString());

                        var childern = RoomData.Where(a => a.adultNo == specRoom.Adults && a.childernNo == specRoom.Childern).ToList();
                        if (childern.Count == 1)
                        {
                            var childages = childern[0].childAge.Split('-');
                            traveller.ChildAge.AddRange(childages.ToList());
                        }
                        else
                        {
                            var child     = RoomData.FirstOrDefault(a => a.adultNo == specRoom.Adults && a.childernNo == specRoom.Childern && a.roomNo == item.RoomRef);
                            var childages = child.childAge.Split('-');
                            traveller.ChildAge.AddRange(childages.ToList());
                        }
                    }
                    confirmationModel.travellers.Add(traveller);
                }
                foreach (var item in searchRoomResults)
                {
                    ConfirmedRoom confirmedRoom = new ConfirmedRoom();
                    if (BookingData.Provider_ID == "5")
                    {
                        var roomNo = int.Parse(item.RoomCode);
                        confirmedRoom.Adult = RoomData.FirstOrDefault(ad => ad.roomNo == roomNo).adultNo ?? default(int);
                        confirmedRoom.Child = RoomData.FirstOrDefault(ad => ad.roomNo == roomNo).childernNo ?? default(int);
                    }
                    else
                    {
                        confirmedRoom.Adult = item.Adults.Value;
                        confirmedRoom.Child = item.Childern.Value;
                    }
                    //var  RoomsImage = hotelsImage.Where(a => a.Category.ToLower() == "hotel rooms").ToList();
                    //***************
                    //if (RoomsImage.Count > 0)
                    //{
                    //confirmedRoom.Image = RoomsImage[0].URL;
                    //}
                    confirmedRoom.IsRefundable = item.IsRefundable.Value;
                    confirmedRoom.Paxs         = item.PaxSQty.Value;
                    confirmedRoom.RoomCode     = item.RoomCode;
                    confirmedRoom.RoomMeal     = item.meal;
                    confirmedRoom.RoomType     = item.RoomName;
                    confirmedRoom.RateType     = item.rateType;
                    List <CancelPolicy> cancelPolicies = new List <CancelPolicy>();
                    using (HotelBookingDBEntities db = new HotelBookingDBEntities())
                    {
                        cancelPolicies = db.CancelPolicies.Where(a => a.Sid == sid && a.HotelCode == BookingData.Hotel_ID && a.RoomCode.ToString() == item.RoomCode && a.ProviderID == BookingData.Provider_ID).ToList();
                    }

                    if (cancelPolicies.Count > 0)
                    {
                        foreach (var p in cancelPolicies)
                        {
                            CancellationRule cancellation = new CancellationRule();
                            cancellation.FromDate = p.FromDate.ToString();
                            if (BookingData.Sell_Currency == p.Currency)
                            {
                                cancellation.Price = (double)p.SellPrice.Value;
                            }
                            else
                            {
                                cancellation.Price = (double)p.SellPrice.Value * ExcahngeRate;
                            }

                            cancellation.CanellationRuleText = cancellation.Price + " " + BookingData.Sell_Currency + " From " + p.FromDate.Value.ToString("MMMM dd, yyyy");
                            confirmedRoom.cancellations.Add(cancellation);
                        }
                    }
                    confirmationModel.rooms.Add(confirmedRoom);
                }
                var ConfData = HBDB.BookingConfirmations.FirstOrDefault(a => a.BookingNum == BN);
                if (ConfData != null)
                {
                    confirmationModel.PayableNote = "Payable through  " + ConfData.supplier + ", acting as agent for the service operating company, details of which can be provided upon request. VAT: " + ConfData.Remark + " Reference:" + ConfData.Reference;
                }
                return(confirmationModel);
            }catch (Exception ex)
            {
                LoggingHelper.WriteToFile("ConfirmationController/ERROR/", "ConfirmationDAL" + "INDAL" + sid, "ConfirmData", "Sid is " + sid + " and Booking is" + BN + ex.InnerException?.Message + ex.Message + ex.StackTrace);

                return(null);
            }
        }