public void ApplyRoomsBusiness(List <RoomResult> rooms) { CurrencyManager currencyManager = new CurrencyManager(); SalesRulesManager ServiceChargeManager = new SalesRulesManager(); SalesRulesManager CancellationChargeManager = new SalesRulesManager(); var BaseCur = ConfigurationSettings.AppSettings["BaseCur"]; double ProviderExcahngeRate = currencyManager.GetCurrencyConversion(searchOutputs[0].MinHotelPrice.Currency, BaseCur, searchData.sID); double ExcahngeRate = currencyManager.GetCurrencyConversion(BaseCur, searchData.Currency, searchData.sID); AppliedSalesRule AppliedCancellationMarkup = CancellationChargeManager.ApplySalesRules("Markup"); List <RoomResult> result = new List <RoomResult>(); // for (int j = 0; j < rooms.Count; j++) // { // for (int x = 0; x < rooms[j].rates.Count; x++) // { // RoomResult room = new RoomResult(); // if (rooms[j].rates[x].net == null) // { // continue; // } // room.CostPrice = Math.Round(double.Parse(rooms[j].rates[x].net), 3); // hotel.costPrice = room.CostPrice; // CancellationChargeManager.SetResultCriteria(hotel.hotelName, hotel.hotelStars, hotel.costPrice, "5"); // ServiceChargeManager.SetResultCriteria(hotel.hotelName, hotel.hotelStars, room.CostPrice // * ProviderExcahngeRate, "4"); // AppliedSalesRule AppliedMarkup = ServiceChargeManager.ApplySalesRules("Markup"); // AppliedSalesRule AppliedDiscount = ServiceChargeManager.ApplySalesRules("Discount"); // 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 = rooms[j].rates[x].rateKey; // reference of provider // ///// // room.RoomCode = rooms[j].code; // ///////// // room.RoomType = rooms[j].name; // standard or double // /////// // room.RoomMeal = rooms[j].rates[x].boardName; // room.Adult = rooms[j].rates[x].adults; // room.Child = rooms[j].rates[x].children; // room.IsRefundable = rooms[j].rates[x].rateClass == "NRF" ? false : true; // /////// // room.Paxs = rooms[j].rates[x].adults + 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 = rooms[j].rates[x].rateClass; // room.rateType = rooms[j].rates[x].rateType; // room.childrenAges = rooms[j].rates[x].childrenAges; // room.paymentType = rooms[j].rates[x].paymentType; // room.boardCode = rooms[j].rates[x].boardCode; // room.cancellationRules = rooms[j].rates[x].cancellationPolicies == null ? // new List<CancellationRule>() { new CancellationRule // { Cost = 0, Price = 0, CanellationRuleText = null, FromDate = null, ToDate = null } } : // 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(); // } // } }
public List <PaymentGateWay> GetPayGateWay(string BN) { try { // get Some data from DB like Currency and pos PayLinkDB DB = new PayLinkDB(); SalesRulesManager ServiceChargeManager = new SalesRulesManager(); string pos; List <string> gates = new List <string>(); List <PaymentGateWay> paymentGateWays = new List <PaymentGateWay>(); // SalesRuleGateway salesRule = new SalesRuleGateway(); SalesRules salesRule = new SalesRules(); var criterais = DB.GetDataForGatewayDA(BN); //call selected Gateway //basecurr var BaseCur = ConfigurationSettings.AppSettings["BaseCur"]; // exchangeRate CurrencyRepo currencyManager = new CurrencyRepo(); double ExcahngeRate = currencyManager.GetEveryDayCurrenciesConversion(BaseCur, criterais.Curr, criterais.searchData.sID, DateTime.Now).Result.Customer_Sell_Rate; double ExcahngeRateForBase = currencyManager.GetEveryDayCurrenciesConversion(criterais.Curr, BaseCur, criterais.searchData.sID, DateTime.Now).Result.Customer_Sell_Rate; if (criterais.Curr != null & criterais.pos != null) { gates = GateWays.GetPaymentGatewaysAsync(criterais.Curr).Result; if (gates.Count == 0) { return(null); } } else { return(null); } // call sales Rules salesRule = GateWays.GetSaleRuleForGateAsync(criterais.pos).Result; if (salesRule.MarkupList.Count == 0) { foreach (var item in gates) { PaymentGateWay gateWay = new PaymentGateWay(); gateWay.paymentMethod = item; gateWay.currency = criterais.Curr; gateWay.amount = 0; paymentGateWays.Add(gateWay); } return(paymentGateWays); } ServiceChargeManager.FillPaySaleRules(salesRule); ServiceChargeManager.PrepareSearchCriteriaDic(criterais.searchData); foreach (var item in gates) { ServiceChargeManager.SetResultCriteriaForpay(criterais.HotelName, criterais.HotelStars, criterais.cost * ExcahngeRateForBase, criterais.Pid, item); //AppliedSalesRule AppliedMarkup = ServiceChargeManager.ApplySalesRules("Markup"); AppliedSalesRule AppliedMarkup = ServiceChargeManager.ApplyMarkupForPayGateway(); PaymentGateWay gateWay = new PaymentGateWay(); gateWay.paymentMethod = item; gateWay.currency = criterais.Curr; if (gateWay.currency.ToLower() == "kwd") { gateWay.amount = Math.Round(AppliedMarkup.Value * ExcahngeRate, 3); } gateWay.amount = Math.Round(AppliedMarkup.Value * ExcahngeRate, 2); paymentGateWays.Add(gateWay); } return(paymentGateWays); /// AppliedSalesRule AppliedDiscount = ServiceChargeManager.ApplySalesRules("Discount"); // map /* foreach (var item in salesRule.MarkupList) * { * foreach (var gate in item.CriteriaList) * { * foreach (var g in gates) * { * * * if (g.ToLower() == gate.value.ToLower()) * { * PaymentGateWay gateWay = new PaymentGateWay(); * gateWay.paymentMethod = g; * gateWay.currency = BaseCur; * gateWay.amount = item.commAmount; * gateWay.exchangeRate = ExcahngeRate; * paymentGateWays.Add(gateWay); * } * } * } * }*/ } catch (Exception ex) { return(null); } }
// 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()); } }
/// <summary> /// /// </summary> /// <param name="availability"></param> /// <param name="Curr">user selected curency</param> /// <param name="src"></param> /// <returns></returns> public static CheckAvailabilityResult checkAvailabilityManager(Hotels.Common.Models.AvailabilityReq availability, string Curr, string src) { CheckAvailabilityResult availabilityResult = new CheckAvailabilityResult(); //try //{ CurrencyManager currencyManager = new CurrencyManager(); SalesRulesManager CancellationChargeManager = new SalesRulesManager(); CheckAvailabilityRepo.SaveRequestToDB(availability); double TotalCost = 0; double ProviderExcahngeRate = 0; double newcost = 0; var SearchData = SearchRepo.GetSearchDataBySession(availability.Sid); int duration = SearchData.duration ?? default(int);//Convert.ToInt32((SearchData.dateTo - SearchData.dateFrom).Value.TotalDays); var BaseCur = ConfigurationSettings.AppSettings["BaseCur"]; if (SearchData != null) { availabilityResult = GetRoomsFromProviders(availability, Convert.ToDateTime(SearchData.dateFrom).ToString("yyyy-MM-dd"), duration.ToString()); if (availabilityResult == null) { return(null); } if (availability.PID == "5") { ProviderExcahngeRate = currencyManager.GetCurrencyConversion(Curr, BaseCur, availability.Sid); } if (availability.PID == "4") { // get Hotel Beds provider Curency var HotelBedsCur = ConfigurationSettings.AppSettings["HotelBedsCurency"]; ProviderExcahngeRate = currencyManager.GetCurrencyConversion(HotelBedsCur, BaseCur, availability.Sid); ////ProviderExcahngeRate = currencyManager.GetCurrencyConversion("EUR", BaseCur);availabilityResult.ProviderCur } else if (availability.PID == "2") { ProviderExcahngeRate = currencyManager.GetCurrencyConversion(availabilityResult.ProviderCur, BaseCur, availability.Sid); ////providerexcahngerate = currencymanager.getcurrencyconversion("usd", basecur, availability.sid); } if (Curr == null) { Curr = SearchData.currency; } double ExcahngeRate = currencyManager.GetCurrencyConversion(BaseCur, Curr, availability.Sid); double MarkUpRate = currencyManager.GetCurrencyConversion(BaseCur, SearchData.currency, availability.Sid); var roomsRules = AvailabiltyRooms.getRoomsRules(availability.HotelCode, availability.Sid, availability.PID); if (roomsRules == null) { return(null); } AppliedSalesRule AppliedCancellationMarkup = CancellationChargeManager.ApplySalesRules("Markup"); for (int i = 0; i < availabilityResult.Result.Count; i++) { var roomData = roomsRules.FirstOrDefault(a => a.RoomCode == availabilityResult.Result[i].RoomIndex.ToString()); availabilityResult.Result[i].RatePerNight = ((availabilityResult.Result[i].CostPrice * ProviderExcahngeRate / duration) + (roomData.MarkupVal.Value / MarkUpRate) - (roomData.DiscountVal.Value / MarkUpRate)) * ExcahngeRate; availabilityResult.Result[i].TotalSellPrice = Math.Round(availabilityResult.Result[i].RatePerNight * duration, 3); TotalCost += availabilityResult.Result[i].CostPrice; foreach (var item in availabilityResult.Result[i].cancellationRules) //// { item.Price = Math.Round(((item.Cost * ProviderExcahngeRate) + AppliedCancellationMarkup.Value) * ExcahngeRate, 3); item.CanellationRuleText = SearchData.language.ToLower() == "en" ? Math.Round(((item.Cost * ProviderExcahngeRate) + AppliedCancellationMarkup.Value) * ExcahngeRate, 3) + " " + SearchData.currency + " of the booking amount " + item.FromDate : item.FromDate + " TO " + "" + SearchData.currency + Math.Round(((item.Cost * ProviderExcahngeRate) + AppliedCancellationMarkup.Value) * ExcahngeRate, 3); } } newcost = availability.TotalCost; //availabilityResult.TotalCost = TotalCost; } CheckAvailabilityRepo.SaveResponseToDB(availabilityResult, newcost, availability, SearchData.currency, src); return(availabilityResult); //} //catch (Exception ex) //{ // LoggingHelper.WriteToFile("AvailabilityController/Errors/", "AvailabilityController" + "providerManagement" + availability.Sid, ex.InnerException?.Message, ex.Message + ex.StackTrace); // return null; //} }
//map tbo rooms rsp to general res public static HotelSearchRoom MapTboRoomRspTogenrl(HotelRoomAvailabilityResponse response, string SID) { if (response.HotelRooms == null) { return(null); } //get ADT CHD NO SearchRepo manager = new SearchRepo(); var rooms = manager.GetADTCHDNoBySid(SID); CurrencyManager currencyManager = new CurrencyManager(); SalesRulesManager ServiceChargeManager = new SalesRulesManager(); SalesRulesManager CancellationChargeManager = new SalesRulesManager(); var BaseCur = ConfigurationSettings.AppSettings["BaseCur"]; double ProviderExcahngeRate = currencyManager.GetCurrencyConversion(response.HotelRooms[0].RoomRate.Currency, BaseCur, SID); double ExcahngeRate = currencyManager.GetCurrencyConversion(BaseCur, response.HotelRooms[0].RoomRate.Currency, SID); AppliedSalesRule AppliedCancellationMarkup = CancellationChargeManager.ApplySalesRules("Markup"); // //options for booking List <OptionsForBooking> options = new List <OptionsForBooking>(); foreach (var item in response.OptionsForBooking.RoomCombination) { options.Add(new OptionsForBooking { RoomIndex = item.RoomIndex }); } List <RoomResult> roomResults = new List <RoomResult>(); foreach (var item in response.HotelRooms.ToList()) { //supplements List <Hotels.Common.Models.RoomResult.Supplement> supplements = new List <Hotels.Common.Models.RoomResult.Supplement>(); if (item.Supplements != null) { foreach (var sup in item.Supplements) { supplements.Add(new Hotels.Common.Models.RoomResult.Supplement { Price = sup.Price, SuppChargeType = sup.SuppChargeType.ToString(), SuppID = sup.SuppID, SuppIsSelected = sup.SuppIsMandatory, Cur = sup.CurrencyCode, }); } } List <CancellationRule> cancellationRules = new List <CancellationRule>(); foreach (var cancel in item.CancelPolicies.CancelPolicy) { double costToSave = 0; string Cur = ""; //Enum.TryParse(cancel.ChargeType.ToString(), out CancellationChargeTypeForHotel Type); if (cancel.ChargeType == CancellationChargeTypeForHotel.Percentage) { costToSave = (double)cancel.CancellationCharge; Cur = "%"; } else { Cur = "KWD"; costToSave = (double)cancel.CancellationCharge * ProviderExcahngeRate; //Math.Round((double)cancel.CancellationCharge * ProviderExcahngeRate, 3); } cancellationRules.Add(new CancellationRule { Price = costToSave, Curency = Cur, FromDate = cancel.FromDate, ToDate = cancel.ToDate, //Cost = (double)cancel.CancellationCharge, Cost = (double)cancel.CancellationCharge, ChargeType = cancel.ChargeType.ToString(), }); } //foreach (var PaxNo in rooms) //{ roomResults.Add(new RoomResult { RoomIndex = item.RoomIndex, RoomType = item.RoomTypeName + " " + item?.RoomPromtion, //RoomCode = item.RoomIndex, RoomCode = item.RoomTypeCode, RoomReference = item.RatePlanCode, //Adult = rooms.FirstOrDefault(ad=>ad.roomNo == item.RoomIndex).adultNo ?? default(int), //Child = rooms.FirstOrDefault(ad => ad.roomNo == item.RoomIndex).childernNo ?? default(int), // RatePerNight = ((double)item.RoomRate.TotalFare * ProviderExcahngeRate ) * ExcahngeRate, //TotalSellPrice = Math.Round(((double)item.RoomRate.TotalFare * ProviderExcahngeRate) * ExcahngeRate, 3), //tax rateType = item.RoomRate.RoomTax.ToString(), //base rateClass = item.RoomRate.RoomFare.ToString(), //RatePerNight = (double)item.RoomRate.DayRates[0].BaseFare, CostPrice = (double)item.RoomRate.TotalFare, Tax = item.RoomRate.RoomTax, RoomMeal = item.MealType, //sell curency kwd Curency = BaseCur, TotalSellPrice = Math.Round((double)item.RoomRate.TotalFare * ProviderExcahngeRate, 3), Supplements = supplements, cancellationRules = cancellationRules, Images = item?.RoomAdditionalInfo?.ImageURLs.ToList(), Amenities = item.Amenities, Inclusion = item.Inclusion }); //} } HotelSearchRoom hotelSearchRoom = new HotelSearchRoom(); int PkageNO = 0; foreach (var item in options) { PkageNO++; SearchRoomData roomresult = new SearchRoomData(); roomresult = null; SeparatedRoom srts = new SeparatedRoom(); for (int i = 0; i < item.RoomIndex.Count(); i++) { var resultsR = roomResults.Where(res => res.RoomIndex == item.RoomIndex[i]).FirstOrDefault(); resultsR.PackageNO = PkageNO; srts.RoomResults.Add(resultsR); } hotelSearchRoom.rooms.Add(srts); } SeparatedRoom separatedRoom = new SeparatedRoom { OptionsForBookings = options, RoomResults = roomResults }; var singles = roomResults.GroupBy(n => n.RoomCode).ToList() //.Where(g => g.Count() == 1) .Select(g => g.First()).ToList(); hotelSearchRoom.Packages = singles; return(hotelSearchRoom); }
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()); } }
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>()); } }
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>()); } }