public ValidationData MappingDataQuate(GraphQLResponse data, string SessionID) { try { ValidationData OutPutData = new ValidationData(); OutPutData.cancelPolicy.refundable = data.Data.hotelX.quote.optionQuote.cancelPolicy.refundable; if (data.Data.hotelX.quote.optionQuote.cancelPolicy.cancelPenalties != null) { foreach (var item in data.Data.hotelX.quote.optionQuote.cancelPolicy.cancelPenalties) { var cancel = new CancelPenalty(); cancel.currency = item.currency; cancel.hoursBefore = item.hoursBefore; cancel.value = item.value; cancel.penaltyType = item.penaltyType; OutPutData.cancelPolicy.cancelPenalties.Add(cancel); } } OutPutData.optionRefId = data.Data.hotelX.quote.optionQuote.optionRefId; OutPutData.price.currency = data.Data.hotelX.quote.optionQuote.price.currency; OutPutData.price.net = data.Data.hotelX.quote.optionQuote.price.net; OutPutData.status = data.Data.hotelX.quote.optionQuote.status; return(OutPutData); } catch (Exception ex) { var requestData = JsonConvert.SerializeObject(ex); LoggerHelper.WriteToFile("SMLogs/ValidationMapException", "ValidationMapException_" + SessionID, "ValidationMapException", requestData); throw; } }
public async Task <CancelPolicy> GETPolicyDetails(string HotelId, string SessionID) { CancelPolicy policy = new CancelPolicy(); using (SqlCommand cmd = new SqlCommand("MS_SelectCancelPolicy", Db_Con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("sessionID", SessionID); cmd.Parameters.AddWithValue("HotelID", HotelId); var reader = cmd.ExecuteReader(); while (reader.Read()) { CancelPenalty cancel = new CancelPenalty(); cancel.currency = reader["Currency"].ToString(); cancel.hoursBefore = int.Parse(reader["hoursBefore"].ToString()); cancel.penaltyType = reader["Type"].ToString(); cancel.value = float.Parse(reader["Value"].ToString()); policy.refundable = bool.Parse(reader["PolicyRefundable"].ToString()); policy.cancelPenalties.Add(cancel); // TestList.Add(test); } } return(policy); }
//增量获取不删除rateplan,直接更新此处 public void InsertRate(int ratePlanId, IList <OTA_HotelRatePlanRS.RatePlansLocalType.RatePlanLocalType.RatesLocalType> rates, bool ifNeedCheck = false) { if (Check(rates)) { foreach (var item in rates[0].Rate) { using (var context = new TravelDBContext()) { int RateInserted = -1; EfRepository <Rate> rateContext = new EfRepository <Rate>(context); EfRepository <BaseByGuestAmt> baseByGuestContext = new EfRepository <BaseByGuestAmt>(context); DateTime startDate = Convert.ToDateTime(item.Start); DateTime endDate = Convert.ToDateTime(item.End); if (ifNeedCheck) { var checkDataExists = (from r in rateContext.Table where r.RatePlanId == ratePlanId && r.Start.Value >= startDate && r.End.Value <= endDate select r).ToList(); if (checkDataExists.Count > 0) { LoggerHelper(ratePlanId.ToString(), "Rate" + startDate + "," + endDate + " Deleted"); rateContext.Delete(checkDataExists); } } Rate rate = new Rate(); rate.RatePlanId = ratePlanId; rate.Start = startDate; rate.End = endDate; rate.IsInstantConfirm = Convert.ToBoolean(item.IsInstantConfirm); rate.Status = item.Status; rate.NumberOfUnits = Convert.ToInt32(item.NumberOfUnits); var mealIncluded = item.MealsIncluded; if (Check(mealIncluded)) { rate.IsBreakfast = Convert.ToBoolean(mealIncluded[0].Breakfast); rate.BreakfastNumber = Convert.ToInt32(mealIncluded[0].NumberOfBreakfast); } rate.LastModifyTime = DateTime.Now; rateContext.Insert(rate); LoggerHelper(ratePlanId.ToString(), "RAte" + rate.Start + "," + rate.End + "Inserted"); RateInserted = rate.Id; var BaseByGuestAmts = item.BaseByGuestAmts; if (Check(BaseByGuestAmts)) { var BaseByGuestAmtItem = BaseByGuestAmts[0].BaseByGuestAmt[0]; BaseByGuestAmt bga = new BaseByGuestAmt(); bga.AmountBeforeTax = Convert.ToDecimal(BaseByGuestAmtItem.AmountBeforeTax); bga.CurrencyCode = BaseByGuestAmtItem.CurrencyCode; bga.NumberOfGuests = Convert.ToInt32(BaseByGuestAmtItem.NumberOfGuests); bga.RateId = RateInserted; bga.ListPrice = Convert.ToDecimal(BaseByGuestAmtItem.ListPrice); var tap_extension = BaseByGuestAmtItem.TPA_Extensions; if (Check(tap_extension)) { var otherCurrency = tap_extension[0].OtherCurrency[0]; var AmountPercentType = otherCurrency.AmountPercentType[0]; var Amount = AmountPercentType.Amount; var CurrencyCode = AmountPercentType.CurrencyCode; bga.OtherCurrency = Convert.ToDecimal(Amount); bga.OtherCurrencyCode = CurrencyCode; } bga.LastModifyTime = DateTime.Now; baseByGuestContext.Insert(bga); LoggerHelper(ratePlanId.ToString(), "BaseByGuestAmts" + bga.AmountBeforeTax + "," + bga.CurrencyCode + "Inserted"); } var Fees = item.Fees; if (Check(Fees)) { EfRepository <Fee> feeContext = new EfRepository <Fee>(context); foreach (var fee in Fees[0].Fee) { Fee f = new Fee(); f.Code = Convert.ToInt32(fee.Code); f.Amount = Convert.ToDecimal(fee.Amount); f.CurrencyCode = fee.CurrencyCode; f.ChargeUnit = Convert.ToInt32(fee.ChargeUnit); f.RateId = RateInserted; f.LastModifyTime = DateTime.Now; f.RateId = RateInserted; var Description = fee.Description; if (Check(Description)) { f.DescriptionText = Description[0].Text; } f.LastModifyTime = DateTime.Now; var feeExtension = fee.TPA_Extensions; if (Check(feeExtension)) { var otherCurrency = feeExtension[0].OtherCurrency[0]; var AmountPercentType = otherCurrency.AmountPercentType[0]; var feeAmount = AmountPercentType.Amount; var Currency = AmountPercentType.CurrencyCode; LoggerHelper(ratePlanId.ToString(), "Fee Other Currency :" + Currency + "," + feeAmount); } feeContext.Insert(f); LoggerHelper(ratePlanId, "Fee Other Currency Finished"); } } var GuaranteePolicies = item.GuaranteePolicies; if (Check(GuaranteePolicies)) { EfRepository <GuaranteePolicy> guaranteePolicyContext = new EfRepository <GuaranteePolicy>(context); GuaranteePolicy gp = new GuaranteePolicy(); gp.RateId = RateInserted; gp.GuaranteeCode = Convert.ToInt32(GuaranteePolicies[0].GuaranteePolicy[0].GuaranteeCode); var Holdtime = GuaranteePolicies[0].GuaranteePolicy[0].HoldTime; if (!string.IsNullOrEmpty(Holdtime)) { gp.HoldTime = Convert.ToDateTime(Holdtime); } gp.LastModifyTime = DateTime.Now; guaranteePolicyContext.Insert(gp); } var CancelPolicies = item.CancelPolicies; if (Check(CancelPolicies)) { EfRepository <CancelPenalty> cancleContext = new EfRepository <CancelPenalty>(context); CancelPenalty cp = new CancelPenalty(); var CancelPolicy = CancelPolicies[0].CancelPenalty[0]; cp.Start = Convert.ToDateTime(CancelPolicy.Start); cp.End = Convert.ToDateTime(CancelPolicy.End); cp.RateId = RateInserted; var AmountPercent = CancelPolicy.AmountPercent[0]; cp.AmountPercent = Convert.ToDecimal(AmountPercent.Amount); cp.CurrencyCode = AmountPercent.CurrencyCode; var CancleExtension = CancelPolicy.TPA_Extensions; if (Check(CancleExtension)) { var otherCurrency = CancleExtension[0].OtherCurrency[0]; var AmountPercentType = otherCurrency.AmountPercentType[0]; cp.OtherCurrencyAmount = Convert.ToDecimal(AmountPercentType.Amount); cp.OtherCurrencyCode = AmountPercentType.CurrencyCode; cancleContext.Insert(cp); LoggerHelper(ratePlanId, "Cancle Pennalty " + cp.OtherCurrencyAmount + "Inserted"); } } var rateExtension = item.TPA_Extensions; if (Check(rateExtension)) { var RebatePromotion = rateExtension[0].RebatePromotion; if (Check(RebatePromotion)) { EfRepository <RateExtension> rateExtensionContext = new EfRepository <RateExtension>(context); RateExtension re = new RateExtension(); foreach (var rebate in RebatePromotion) { re.StartPeriod = Convert.ToDateTime(rebate.StartPeriod); re.EndPeriod = Convert.ToDateTime(rebate.EndPeriod); re.ProgramName = rebate.ProgramName; re.Amount = Convert.ToDecimal(rebate.Amount); re.CurrencyCode = rebate.CurrencyCode; re.Code = Convert.ToInt32(rebate.Code); re.RateId = RateInserted; if (Check(rebate.Description)) { var des = rebate.Description[0].Text; re.DescriptionText = des; Console.WriteLine(des); } } re.LastModifyTime = DateTime.Now; rateExtensionContext.Insert(re); } var PayChange = rateExtension[0].PayChange; Console.WriteLine(PayChange); } } } } }
public Bookingback MapResponseofBooking(dynamic OutPutData, string sessionId) { try { var BackData = new Bookingback(); BackData.reference.client = OutPutData.reference.client; BackData.reference.supplier = OutPutData.reference.supplier; if (OutPutData.holder == null) { BackData.holder = null; } else { BackData.holder.name = OutPutData.holder.name; BackData.holder.surname = OutPutData.holder.surname; } if (OutPutData.hotel == null) { BackData.hotel = null; } else { BackData.hotel.boardCode = OutPutData.hotel.boardCode; BackData.hotel.checkIn = OutPutData.hotel.checkIn; BackData.hotel.checkOut = OutPutData.hotel.checkOut; BackData.hotel.creationDate = OutPutData.hotel.creationDate; BackData.hotel.hotelCode = OutPutData.hotel.hotelCode; BackData.hotel.hotelName = OutPutData.hotel.hotelName; if (OutPutData.hotel.rooms != null) { foreach (var item in OutPutData.hotel.rooms) { BookingRoom room = new BookingRoom(); room.code = item.code; room.description = item.description; room.occupancyRefId = item.occupancyRefId; room.price.currency = item.price.currency; room.price.net = item.price.net; room.price.gross = item.price.gross; room.price.binding = item.price.binding; room.price.exchange.currency = item.price.exchange.currency; room.price.exchange.rate = item.price.exchange.rate; BackData.hotel.rooms.Add(room); } } if (OutPutData.hotel.occupancies != null) { foreach (var p in OutPutData.hotel.occupancies) { PaxBack roomPax = new PaxBack(); roomPax.id = p.id; foreach (var x in p.paxes) { Pax pax = new Pax(); pax.age = x.age; roomPax.paxes.Add(pax); } BackData.hotel.occupancies.Add(roomPax); } } } BackData.price.currency = OutPutData.price.currency; BackData.price.net = OutPutData.price.net; BackData.price.gross = OutPutData.price.gross; BackData.status = OutPutData.status; BackData.remarks = OutPutData.remarks; BackData.payable = OutPutData.payable; if (OutPutData.cancelPolicy != null) { BackData.cancelPolicy.refundable = OutPutData.cancelPolicy.refundable; foreach (var c in OutPutData.cancelPolicy.cancelPenalties) { CancelPenalty cancelPenalty = new CancelPenalty(); cancelPenalty.currency = c.currency; cancelPenalty.hoursBefore = c.hoursBefore; cancelPenalty.value = c.value; cancelPenalty.penaltyType = c.penaltyType; BackData.cancelPolicy.cancelPenalties.Add(cancelPenalty); } } return(BackData); } catch (Exception ex) { var requestData = JsonConvert.SerializeObject(ex); LoggerHelper.WriteToFile("c:/HotelsB2C/Logs/SMLogs/BookingMapException", "BookingMapException_" + sessionId, "BookingMapException", requestData); throw; } }