Пример #1
0
        private static bool SaveFareComponent(int flightId, PassengerType passengerType, FareComponent fareComponent)
        {
            var db = new MySqlDatabase(DbConfiguration.ReservationDB);
            var cmd = CommandBuilder.BuildInsertFareComponentCommand(flightId, passengerType, fareComponent.Type,
                                                                     fareComponent.Amount, fareComponent.Name,
                                                                     db.Connection);

            db.ExecuteNonQuery(cmd);

            return true;
        }
Пример #2
0
        private static AirFare ParsePassengerFareBreadowns(JetModel.PTCFareBreakdownType[] fareBreakdown, int adultCount, int childCount, int infantCount, bool useQuantityFromResponse)
        {
            if (fareBreakdown == null || fareBreakdown.Length == 0)
                return null;
            AirFare airFare = new AirFare();
            airFare.PassengerFares = new List<PassengerFare>();
            foreach (JetModel.PTCFareBreakdownType paxFbt in fareBreakdown)
            {
                if (paxFbt.PassengerFare == null) return null;
                PassengerFare paxFare = new PassengerFare();
                paxFare.PassengerType = ParsePassengerCode(paxFbt.PassengerTypeQuantity.Code);
                if(useQuantityFromResponse)
                {
                    paxFare.Quantity = Int32.Parse(paxFbt.PassengerTypeQuantity.Quantity);
                }
                else
                {
                    if (paxFare.PassengerType == PassengerType.Adult)
                        paxFare.Quantity = adultCount;
                    else if (paxFare.PassengerType == PassengerType.Child)
                        paxFare.Quantity = childCount;
                    else if (paxFare.PassengerType == PassengerType.Infant)
                        paxFare.Quantity = infantCount;
                }

                paxFare.BaseFare = paxFbt.PassengerFare.BaseFare.Amount;
                paxFare.Currency = paxFbt.PassengerFare.BaseFare.CurrencyCode;
                paxFare.Taxes = new List<FareComponent>();
                if (paxFbt.PassengerFare.Taxes != null)
                {
                    foreach (JetModel.AirTaxType tax in paxFbt.PassengerFare.Taxes)
                    {
                        FareComponent taxComponant = new FareComponent()
                                                         {
                                                             Amount = tax.Amount,
                                                             Type = tax.TaxCode
                                                         };
                        paxFare.Taxes.Add(taxComponant);
                    }
                }
                if (paxFbt.FareBasisCodes != null)
                {
                    foreach (string code in paxFbt.FareBasisCodes)
                    {
                        paxFare.FareBasisCode = (!string.IsNullOrEmpty(paxFare.FareBasisCode) ? paxFare.FareBasisCode + "," : string.Empty) + code;
                    }
                }
                if (paxFbt.FareInfo != null)
                {
                    foreach (JetModel.FareReference info in paxFbt.FareInfo[0].FareReference)
                    {
                        paxFare.ClassOfService = (!string.IsNullOrEmpty(paxFare.ClassOfService) ? paxFare.ClassOfService + "," : string.Empty) +
                                         info.ResBookDesigCode;
                        paxFare.CabinClass = (!string.IsNullOrEmpty(paxFare.CabinClass) ? paxFare.CabinClass + "," : string.Empty) + info.Value;
                    }
                }
                airFare.PassengerFares.Add(paxFare);
            }
            return airFare;
        }