private Fare BuildFlightFare(FareInformation fareInfo)
        {
            Fare fare = new Fare();

            decimal baseFare   = 0;
            decimal changeCost = 0;
            decimal discount   = 0;
            decimal tax        = 0;

            if (fareInfo != null)
            {
                if (fareInfo.AdultFares != null)
                {
                    foreach (var AdultFare in fareInfo.AdultFares)
                    {
                        if (!string.IsNullOrEmpty(AdultFare.BaseAdultFarePerPax))
                        {
                            baseFare += Convert.ToDecimal(AdultFare.BaseAdultFarePerPax) * Convert.ToDecimal(AdultFare.PaxCount);
                        }

                        if (!string.IsNullOrEmpty(AdultFare.DiscountPerPax))
                        {
                            discount += Convert.ToDecimal(AdultFare.DiscountPerPax) * Convert.ToDecimal(AdultFare.PaxCount);
                        }

                        if (!string.IsNullOrEmpty(AdultFare.TaxPerPax))
                        {
                            tax += Convert.ToDecimal(AdultFare.TaxPerPax) * Convert.ToDecimal(AdultFare.PaxCount);
                        }

                        //if (!string.IsNullOrEmpty(AdultFare.ChangeCost))
                        //    changeCost += Convert.ToDecimal(AdultFare.ChangeCost) * Convert.ToDecimal(AdultFare.PaxCount);
                    }
                }

                if (fareInfo.ChildFares != null)
                {
                    foreach (var ChildFare in fareInfo.ChildFares)
                    {
                        if (!string.IsNullOrEmpty(ChildFare.BaseChildFarePerPax))
                        {
                            baseFare += Convert.ToDecimal(ChildFare.BaseChildFarePerPax) * Convert.ToDecimal(ChildFare.PaxCount);
                        }

                        if (!string.IsNullOrEmpty(ChildFare.DiscountPerPax))
                        {
                            discount += Convert.ToDecimal(ChildFare.DiscountPerPax) * Convert.ToDecimal(ChildFare.PaxCount);
                        }
                        ;

                        if (!string.IsNullOrEmpty(ChildFare.TaxPerPax))
                        {
                            tax += Convert.ToDecimal(ChildFare.TaxPerPax) * Convert.ToDecimal(ChildFare.PaxCount);
                        }

                        //if (!string.IsNullOrEmpty(ChildFare.ChangeCost))
                        //    changeCost += Convert.ToDecimal(ChildFare.ChangeCost) * Convert.ToDecimal(ChildFare.PaxCount);
                    }
                }

                if (fareInfo.InfantFares != null)
                {
                    foreach (var InfantFare in fareInfo.InfantFares)
                    {
                        if (!string.IsNullOrEmpty(InfantFare.BaseInfantFarePerPax))
                        {
                            baseFare += Convert.ToDecimal(InfantFare.BaseInfantFarePerPax) * Convert.ToDecimal(InfantFare.PaxCount);
                        }
                        ;

                        if (!string.IsNullOrEmpty(InfantFare.DiscountPerPax))
                        {
                            discount += Convert.ToDecimal(InfantFare.DiscountPerPax) * Convert.ToDecimal(InfantFare.PaxCount);
                        }
                        ;

                        if (!string.IsNullOrEmpty(InfantFare.TaxPerPax))
                        {
                            tax += Convert.ToDecimal(InfantFare.TaxPerPax) * Convert.ToDecimal(InfantFare.PaxCount);
                        }

                        //if (!string.IsNullOrEmpty(InfantFare.ChangeCost))
                        //    changeCost += Convert.ToDecimal(InfantFare.ChangeCost) * Convert.ToDecimal(InfantFare.PaxCount);
                    }
                }
            }

            fare.BaseFare = CurrencyHelper.ToString(currency, baseFare);
            //fare.ChangeCost = CurrencyHelper.ToString(currency, changeCost);
            fare.Discount  = CurrencyHelper.ToString(currency, discount);
            fare.Tax       = CurrencyHelper.ToString(currency, tax);
            fare.TotalFare = CurrencyHelper.ToString(currency, baseFare + tax);

            fare.CurrencyCode = currency;
            //faresForConversion.Add(fare.BaseFare.Replace(",", ""));

            return(fare);
        }
        private FareInformation BuildFlightFareInformation <T>(IGrouping <T, FlightFare> fType, bool isReprice)
        {
            FareInformation fareInformation = new FareInformation();

            if (fType != null)
            {
                var adulFareInfos = isReprice ? fType.ToList().Where(f => f.PassengerTypeId == Enums.PassengerTypes.Adult && f.WebFareAmount == fType.ToList().Where(g => g.PassengerTypeId == Enums.PassengerTypes.Adult).Min(d => d.WebFareAmount)).GroupBy(x => x.FareAmount) :
                                    fType.ToList().Where(f => f.PassengerTypeId == Enums.PassengerTypes.Adult).GroupBy(x => x.FareAmount);

                if (adulFareInfos != null)
                {
                    var AdultFares = new List <AdultFares>();
                    foreach (var adulFareInfo in adulFareInfos)
                    {
                        AdultFares adultFare = new AdultFares();
                        adultFare.FareId              = Convert.ToString(adulFareInfo.First().FareId);
                        adultFare.FareBasisCode       = adulFareInfo.First().FareBasisCode;
                        adultFare.FareClass           = adulFareInfo.First().FareClass;
                        adultFare.AdultFarePerPax     = CurrencyHelper.ToString(currency, adulFareInfo.First().WebFareAmount);
                        adultFare.BaseAdultFarePerPax = CurrencyHelper.ToString(currency, adulFareInfo.First().DisplayAmountNoTaxes).Replace(",", "");
                        adultFare.DiscountPerPax      = CurrencyHelper.ToString(currency, adulFareInfo.First().Discount);
                        adultFare.PaxCount            = searchCriteria.Adults;
                        adultFare.TaxPerPax           = CurrencyHelper.ToString(currency, adulFareInfo.First().Taxes);
                        AdultFares.Add(adultFare);
                    }
                    fareInformation.AdultFares = AdultFares;
                }
                var childFareInfos = isReprice ? fType.ToList().Where(f => f.PassengerTypeId == Enums.PassengerTypes.Child && f.WebFareAmount == fType.ToList().Where(g => g.PassengerTypeId == Enums.PassengerTypes.Child).Min(d => d.WebFareAmount)).GroupBy(x => x.FareAmount) :
                                     fType.ToList().Where(f => f.PassengerTypeId == Enums.PassengerTypes.Child).GroupBy(x => x.FareAmount);
                if (childFareInfos != null)
                {
                    var ChildFares = new List <ChildFares>();
                    foreach (var childFareInfo in childFareInfos)
                    {
                        ChildFares childFare = new ChildFares();
                        childFare.FareId              = Convert.ToString(childFareInfo.First().FareId);
                        childFare.FareBasisCode       = childFareInfo.First().FareBasisCode;
                        childFare.FareClass           = childFareInfo.First().FareClass;
                        childFare.ChildFarePerPax     = CurrencyHelper.ToString(currency, childFareInfo.First().WebFareAmount);
                        childFare.BaseChildFarePerPax = CurrencyHelper.ToString(currency, childFareInfo.First().DisplayAmountNoTaxes).Replace(",", "");
                        childFare.DiscountPerPax      = CurrencyHelper.ToString(currency, childFareInfo.First().Discount);
                        childFare.PaxCount            = searchCriteria.Children;
                        childFare.TaxPerPax           = CurrencyHelper.ToString(currency, childFareInfo.First().Taxes);
                        ChildFares.Add(childFare);
                    }
                    fareInformation.ChildFares = ChildFares;
                }
                var infantFareInfos = isReprice ? fType.ToList().Where(f => f.PassengerTypeId == Enums.PassengerTypes.Infant && f.WebFareAmount == fType.ToList().Where(g => g.PassengerTypeId == Enums.PassengerTypes.Infant).Min(d => d.WebFareAmount)).GroupBy(x => x.FareAmount) :
                                      fType.ToList().Where(f => f.PassengerTypeId == Enums.PassengerTypes.Infant).GroupBy(x => x.FareAmount);
                if (infantFareInfos != null)
                {
                    var InfantFares = new List <InfantFares>();
                    foreach (var infantFareInfo in infantFareInfos)
                    {
                        InfantFares infantFare = new InfantFares();
                        infantFare.FareId               = Convert.ToString(infantFareInfo.First().FareId);
                        infantFare.FareBasisCode        = infantFareInfo.First().FareBasisCode;
                        infantFare.FareClass            = infantFareInfo.First().FareClass;
                        infantFare.InfantFarePerPax     = CurrencyHelper.ToString(currency, infantFareInfo.First().WebFareAmount);
                        infantFare.BaseInfantFarePerPax = CurrencyHelper.ToString(currency, infantFareInfo.First().DisplayAmountNoTaxes).Replace(",", "");
                        infantFare.DiscountPerPax       = CurrencyHelper.ToString(currency, infantFareInfo.First().Discount);
                        infantFare.PaxCount             = searchCriteria.Infants;
                        infantFare.TaxPerPax            = CurrencyHelper.ToString(currency, infantFareInfo.First().Taxes);
                        InfantFares.Add(infantFare);
                    }
                    fareInformation.InfantFares = InfantFares;
                }
            }
            return(fareInformation);
        }