private OTATravelItineraryObjectHotel GetCars(TravelItinerary.TravelItineraryReadRSTravelItineraryItineraryInfoItemVehicle car, string commission, string dk, string phone, string rfc, string agent, string mail, string sixReceived, string passengerType, int passengerNum, string passengerName, string title, string passengerSurname, string lastStatus, List <string> cancelNumberList) { OTATravelItineraryObjectHotel obj = new OTATravelItineraryObjectHotel(); obj.Provider_Commission = commission; obj.Prov_Direct_Pay = true; obj.DK = dk; obj.Phone = phone; obj.RFC = rfc; obj.User = agent; obj.Mail = mail; obj.Request = sixReceived; obj.CancelNumberList = cancelNumberList; obj.StatusSabre = car.Status; string typeCar = string.Empty; typeCar = car.VehVendorAvail.VehResCore.VehicleCharges.VehicleCharge.GuaranteeInd == null ? string.Empty : car.VehVendorAvail.VehResCore.VehicleCharges.VehicleCharge.GuaranteeInd.Replace("DPST", string.Empty); if (!string.IsNullOrEmpty(typeCar)) { obj.Payment_Form = typeCar.Substring(0, 2).ToUpper(); obj.Car_Number = Convert.ToInt32(typeCar.Substring(typeCar.IndexOf("EXP") - 4, 4)); } else { obj.Payment_Form = string.Empty; obj.Car_Number = 0; } obj.Sales_Source = car.VehRentalCore.LocationDetails.LocationCode.ToUpper(); obj.Provider = "3318"; //OBTENER DE CONSULTA obj.Site = "5475"; //OBTENER DE CONSULTA double total = 0d; double semanal = 0d; foreach (TravelItinerary2.TravelItineraryReadRSTravelItineraryItineraryInfoItemVehicleVehVendorAvailVehResCoreVehicleChargesVehicleChargeApproximateTotalCharge chargeDetails in car.VehVendorAvail.VehResCore.VehicleCharges.VehicleCharge.ChargeDetails == null ? new TravelItinerary2.TravelItineraryReadRSTravelItineraryItineraryInfoItemVehicleVehVendorAvailVehResCoreVehicleChargesVehicleChargeApproximateTotalCharge[0] : car.VehVendorAvail.VehResCore.VehicleCharges.VehicleCharge.ChargeDetails) { if (chargeDetails.RateType == "APPROXIMATE TOTAL PRICE") { //obj.Number_Nights = Convert.ToInt32(chargeDetails.NumDays); total = Convert.ToDouble(chargeDetails.Amount); } if (chargeDetails.RateType == "DAILY RATE") { obj.Cost = Convert.ToDouble(chargeDetails.Amount); } if (chargeDetails.RateType == "WEEKLY RATE") { semanal = Convert.ToDouble(chargeDetails.Amount); } } obj.Number_Nights = (total / 1.16) / obj.Cost; obj.City = car.VehRentalCore.LocationDetails.LocationCode.ToUpper(); obj.In_Date = DateTime.ParseExact(car.VehRentalCore.PickUpDateTime, car.VehRentalCore.PickUpDateTime.Length > 5 ? "MM-ddTHH:mm" : "MM-dd", System.Globalization.CultureInfo.CurrentCulture); obj.Out_Date = DateTime.ParseExact(car.VehRentalCore.ReturnDateTime, car.VehRentalCore.ReturnDateTime.Length > 5 ? "MM-ddTHH:mm" : "MM-dd", System.Globalization.CultureInfo.CurrentCulture); if (obj.Cost.Equals(0)) { if (semanal.Equals(0)) { TimeSpan timespan = obj.Out_Date - obj.In_Date; obj.Number_Nights = timespan.TotalDays; obj.Cost = (total / 1.16) / obj.Number_Nights; } else { obj.Cost = semanal / 7; obj.Number_Nights = (total / 1.16) / obj.Cost; } } else { obj.Number_Nights = (total / 1.16) / obj.Cost; } string codeCityIti = string.Empty; codeCityIti = car.VehRentalCore.LocationDetails.LocationCode; List <ListItem> lstCodCity = new List <ListItem>(); lstCodCity = CatCitiesBL.GetCodeCities(codeCityIti); string country = GetCountryBL.GetCountryByCity(lstCodCity[0].Value); string codeCityDB = string.Empty; if (country.Equals("MX")) { codeCityDB = "AU"; } else { codeCityDB = "AI"; } obj.Service_Type = codeCityDB.ToUpper(); obj.Passenger_Type = passengerType.ToUpper(); obj.Passenger_Num = passengerNum; obj.Passenger_Name = passengerName.ToUpper(); obj.Title = title.ToUpper(); obj.Surname = passengerSurname; obj.Room = "1"; status = car.VehVendorAvail.Vendor.Code.ToUpper(); if (string.IsNullOrEmpty(car.VehRentalCore.LocationDetails.LocationName)) { obj.Hotel = string.Concat(car.VehRentalCore.LocationDetails.LocationCode.ToUpper(), car.VehVendorAvail.Vendor.Code.ToUpper(), "|", GetVendorByCodeBL.GetVendorByCode(car.VehVendorAvail.Vendor.Code.ToUpper()).ToUpper()); } else { string cit = car.VehRentalCore.LocationDetails.LocationName.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries)[0].Substring(0, 3); if (car.VehRentalCore.LocationDetails.LocationName.Length > 3) { string cod = car.VehRentalCore.LocationDetails.LocationName.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries)[0].Substring(3, 1); int numcod = Int32.Parse(Int32.TryParse(car.VehRentalCore.LocationDetails.LocationName.Split( new string[] { " " }, StringSplitOptions.RemoveEmptyEntries )[0].Substring( 4, car.VehRentalCore.LocationDetails.LocationName.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries)[0].Length - 4 ), out numcod) ? car.VehRentalCore.LocationDetails.LocationName.Split( new string[] { " " }, StringSplitOptions.RemoveEmptyEntries )[0].Substring( 4, car.VehRentalCore.LocationDetails.LocationName.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries)[0].Length - 4 ) : "0"); obj.Hotel = string.Concat(cit, car.VehVendorAvail.Vendor.Code.ToUpper(), cod, numcod.ToString("000"), "|", GetVendorByCodeBL.GetVendorByCode(car.VehVendorAvail.Vendor.Code.ToUpper()).ToUpper()); } else { obj.Hotel = string.Concat(cit, car.VehVendorAvail.Vendor.Code.ToUpper(), "|", GetVendorByCodeBL.GetVendorByCode(car.VehVendorAvail.Vendor.Code.ToUpper()).ToUpper()); } } obj.Rate = "VENTA"; obj.Currency = car.VehVendorAvail.VehResCore.VehicleCharges.VehicleCharge.Mileage != null?car.VehVendorAvail.VehResCore.VehicleCharges.VehicleCharge.Mileage.CurrencyCode.ToUpper() : string.Empty; obj.Price = obj.Cost * Convert.ToInt32(obj.Number_Nights); obj.Status = lastStatus; obj.P_Rate = "N/A"; obj.P_Currency = "N/A"; obj.P_IVA = "N/A"; obj.P_ISH = "N/A"; obj.P_Total = "N/A"; if (car.ConfirmationNumber != null) { if (!string.IsNullOrEmpty(car.ConfirmationNumber.ToString())) { obj.Confirmation_Number = car.ConfirmationNumber.ToString().ToUpper(); } } obj.ChainCode = car.VehVendorAvail.Vendor.Code.ToUpper(); DateTime DateIn = DateTime.ParseExact(car.VehRentalCore.PickUpDateTime, car.VehRentalCore.PickUpDateTime.Length > 5 ? "MM-ddTHH:mm" : "MM-dd", System.Globalization.CultureInfo.CurrentCulture); TimeSpan ts = new TimeSpan(); if (DateIn == DateTime.Now) { obj.Time_Limit = DateTime.Now; } else { ts = TimeSpan.FromDays(2); } obj.Time_Limit = DateIn.Subtract(ts); obj.In_City = car.VehVendorAvail.VehResCore.CollectionDeliveryInfo != null? car.VehVendorAvail.VehResCore.CollectionDeliveryInfo.CollectionInfo.Address.CityName.ToUpper() : obj.City; obj.Out_City = car.VehVendorAvail.VehResCore.CollectionDeliveryInfo != null? car.VehVendorAvail.VehResCore.CollectionDeliveryInfo.DeliveryInfo.Address.CityName.ToUpper() : obj.City; string description = string.Empty; string tipoVehiculo = GetTypesCarByCodeBL.GetTypesCarByCode(car.VehVendorAvail.VehResCore.RentalRate.Vehicle.VehType); string equipo = string.Empty; string arrendadora = obj.Hotel.Split('|')[1]; string in_City = GetCityNameBL.GetCityName(obj.In_City); string out_City = GetCityNameBL.GetCityName(obj.Out_City); if (car.VehVendorAvail.VehResCore.PricedEquip.Equipment.SpecialEquipConfirmed == "Y") { equipo = GetEquipmentCarByCodeBL.GetEquipmentCarByCode(car.VehVendorAvail.VehResCore.PricedEquip.Equipment.SpecialEquip).ToUpper(); } description = string.Concat(tipoVehiculo, "|", equipo, "|", arrendadora, "|", in_City, "|", obj.In_Date.ToString(@"dd \de MMMM yyyy HH:mm \HRS", new System.Globalization.CultureInfo("es-MX")), "|", out_City, "|", obj.Out_Date.ToString(@"dd \de MMMM yyyy HH:mm \HRS", new System.Globalization.CultureInfo("es-MX"))); //description = string.Concat("RENTA DE ", !tipoVehiculo.Contains("AUTO") ? "AUTO " : string.Empty, tipoVehiculo, !string.IsNullOrEmpty(equipo) ? " CON " : string.Empty, equipo, " EN ", arrendadora, "); //description = string.Concat(description, "RECIBE: \t", obj.In_Date.ToString(@"dd \de MMMM yyyy HH:mm \HRS", new System.Globalization.CultureInfo("es-MX")), " EN ", arrendadora, " ", in_City, "\n"); //description = string.Concat(description, "ENTREGA:\t", obj.Out_Date.ToString(@"dd \de MMMM yyyy HH:mm \HRS", new System.Globalization.CultureInfo("es-MX")), " EN ", arrendadora, " ", out_City); obj.Description = description.ToUpper(); return(obj); }
private OTATravelItineraryObjectHotel GetHotel(TravelItinerary.TravelItineraryReadRSTravelItineraryItineraryInfoItemHotel hotel, string commission, string dk, string phone, string rfc, string agent, string mail, string sixReceived, string passengerType, int passengerNum, string passengerName, string title, string passengerSurname, string lastStatus, List <string> cancelNumberList) { OTATravelItineraryObjectHotel itineraryObject = new OTATravelItineraryObjectHotel(); itineraryObject.Provider_Commission = commission; itineraryObject.Prov_Direct_Pay = true; itineraryObject.DK = dk; itineraryObject.Phone = phone.ToUpper(); itineraryObject.RFC = rfc; itineraryObject.User = agent; itineraryObject.Mail = mail; itineraryObject.Request = sixReceived; itineraryObject.Passenger_Type = passengerType; itineraryObject.Passenger_Num = passengerNum; itineraryObject.Passenger_Name = passengerName; itineraryObject.Title = title; itineraryObject.Surname = passengerSurname; itineraryObject.CancelNumberList = cancelNumberList; itineraryObject.StatusSabre = hotel.Status; string typeCar = string.Empty; typeCar = hotel.Guarantee.Replace("DPST", string.Empty); itineraryObject.Payment_Form = typeCar.Length > 2 ? typeCar.Substring(0, 2) : string.Empty; itineraryObject.Car_Number = Convert.ToInt32(typeCar.Length > 2 ? typeCar.Substring(typeCar.IndexOf("EXP") - 4, 4) : "0"); itineraryObject.Sales_Source = hotel.BasicPropertyInfo.HotelCityCode; itineraryObject.Provider = "3318"; //OBTENER DE CONSULTA itineraryObject.Site = "5475"; //OBTENER DE CONSULTA itineraryObject.Room = hotel.NumberOfUnits; itineraryObject.City = hotel.BasicPropertyInfo.HotelCityCode; itineraryObject.In_Date = DateTime.ParseExact(hotel.TimeSpan.Start, "MM-dd", System.Globalization.CultureInfo.CurrentCulture); itineraryObject.Out_Date = DateTime.ParseExact(hotel.TimeSpan.End, "MM-dd", System.Globalization.CultureInfo.CurrentCulture); if (itineraryObject.Passenger_Num > 1) { itineraryObject.Room_Type = "Double"; } else { itineraryObject.Room_Type = "Single"; } string codeCityIti = string.Empty; codeCityIti = hotel.BasicPropertyInfo.HotelCityCode; List <ListItem> lstCodCity = new List <ListItem>(); lstCodCity = CatCitiesBL.GetCodeCities(codeCityIti); string country = GetCountryBL.GetCountryByCity(lstCodCity.Count > 0 ? lstCodCity[0].Value : string.Empty); string codeCityDB = string.Empty; if (country.Equals("MX") || string.IsNullOrEmpty(country)) { codeCityDB = "H1"; } else { codeCityDB = "H2"; } itineraryObject.Service_Type = codeCityDB; itineraryObject.Number_Nights = Convert.ToInt32(hotel.TimeSpan.Duration ?? 1.ToString()); status = hotel.BasicPropertyInfo.HotelCode; itineraryObject.Hotel = hotel.BasicPropertyInfo.HotelCode + "|" + hotel.BasicPropertyInfo.HotelName; itineraryObject.Rate = "VENTA"; itineraryObject.Currency = hotel.RoomRates.Rate.CurrencyCode; itineraryObject.Cost = Convert.ToDouble(hotel.RoomRates.Rate.Amount.Substring(0, hotel.RoomRates.Rate.Amount.IndexOf('.') + 3)); itineraryObject.Price = itineraryObject.Cost * Convert.ToInt32(itineraryObject.Number_Nights); itineraryObject.Status = lastStatus; itineraryObject.P_Rate = "N/A"; itineraryObject.P_Currency = "N/A"; itineraryObject.P_IVA = "N/A"; itineraryObject.P_ISH = "N/A"; itineraryObject.P_Total = "N/A"; if (hotel.BasicPropertyInfo.ConfirmationNumber != null) { if (!string.IsNullOrEmpty(hotel.BasicPropertyInfo.ConfirmationNumber[0].ToString())) { itineraryObject.Confirmation_Number = hotel.BasicPropertyInfo.ConfirmationNumber[0].ToString(); } } itineraryObject.ChainCode = hotel.BasicPropertyInfo.ChainCode; DateTime DateIn = DateTime.ParseExact(hotel.TimeSpan.Start, "MM-dd", System.Globalization.CultureInfo.CurrentCulture); TimeSpan ts = new TimeSpan(); if (DateIn == DateTime.Now) { itineraryObject.Time_Limit = DateTime.Now; } else { ts = TimeSpan.FromDays(2); } itineraryObject.Time_Limit = DateIn.Subtract(ts); itineraryObject = (itineraryObject != null) ? itineraryObject : new OTATravelItineraryObjectHotel(); return(itineraryObject); }