/// <summary>
        /// 2. Get farequote request
        /// </summary>
        /// <param name="originAirportCode"></param>
        /// <param name="destAirportCode"></param>
        /// <param name="token"></param>
        /// <param name="adtCount"></param>
        /// <param name="childCount"></param>
        /// <param name="infantCount"></param>
        /// <param name="departureDate"></param>
        /// <param name="returnDate"></param>
        /// <param name="flightNo"></param>
        /// <param name="isRT"></param>
        /// <param name="OBCabin"></param>
        /// <param name="IBCabin"></param>
        /// <returns></returns>
        private List<PaxWiseFareIdResult> CreateFareQuoteRequest(string originAirportCode, string destAirportCode, string token, int adtCount, int childCount, int infantCount,
            DateTime? departureDate, DateTime? returnDate, string OBflightNo, string IBflightNo,
            bool isRT, string OBCabin, string IBCabin)
        {
            List<PaxWiseFareIdResult> colPaxWiseFareIdResult = new List<PaxWiseFareIdResult>();
            PaxWiseFareIdResult objPaxWiseFareId = new PaxWiseFareIdResult();
            if (string.IsNullOrEmpty(OBCabin))
            {
                OBCabin = EnumCabin.Economy.ToString();
            }
            if (string.IsNullOrEmpty(IBCabin))
            {
                IBCabin = EnumCabin.Economy.ToString();
            }
            var OBFareType = (OBCabin.ToLower() == EnumCabin.Economy.ToString().ToLower() ? "Pay To Change" : "Basic");
            var IBFareType = (IBCabin.ToLower() == EnumCabin.Economy.ToString().ToLower() ? "Pay To Change" : "Basic");
            try
            {
                PricingService.CarrierCode[] carrierLst = new PricingService.CarrierCode[1];
                carrierLst[0] = (new PricingService.CarrierCode() { AccessibleCarrierCode = "FZ" });

                using (PricingService.ConnectPoint_Pricing client = new PricingService.ConnectPoint_Pricing())
                {
                    ViewFareQuote ViewFareQuoteResult = client.RetrieveFareQuoteDateRange(new RetrieveFareQuoteByDateRange()
                    {
                        SecurityGUID = token,
                        CarrierCodes = carrierLst,
                        ClientIPAddress = "",
                        CorporationID = -2147483648,
                        CurrencyOfFareQuote = "AED",
                        FareFilterMethod = EnumsFareFilterMethodType.NoCombinabilityRoundtripLowestFarePerFareType,
                        FareGroupMethod = EnumsFareGroupMethodType.WebFareTypes,
                        InventoryFilterMethod = EnumsInventoryFilterMethodType.Available,
                        FareQuoteDetails = GetFareQuoteDetail(originAirportCode, destAirportCode, adtCount, childCount, infantCount, isRT, departureDate, returnDate).ToArray()

                    });

                    if (ViewFareQuoteResult != null && (!string.IsNullOrEmpty(OBflightNo) && !chkRT.Checked) || (!string.IsNullOrEmpty(OBflightNo) && !string.IsNullOrEmpty(IBflightNo)))
                    {

                        if (ViewFareQuoteResult.SegmentDetails != null && ViewFareQuoteResult.SegmentDetails.Count() > 0)
                        {
                            var OBdetail = (from p in ViewFareQuoteResult.SegmentDetails
                                            where p.FlightNum == OBflightNo
                                            select new { p.LFID, p.DepartureDate }).FirstOrDefault();
                            //select fare id for ADT

                            FareType[] fareTypes = (from p in ViewFareQuoteResult.FlightSegments
                                                    where p.LFID == OBdetail.LFID
                                                    select p.FareTypes
                                                 ).FirstOrDefault();
                            FareInfo[] lstFareInfo = (from p in fareTypes
                                                      where p.FareTypeName == OBFareType
                                                      select p.FareInfos
                                                       ).FirstOrDefault();
                            objPaxWiseFareId.LFID = OBdetail.LFID;
                            objPaxWiseFareId.origin = originAirportCode;
                            objPaxWiseFareId.destination = destAirportCode;
                            objPaxWiseFareId.DepartureDate = OBdetail.DepartureDate;
                            objPaxWiseFareId.ADTFareID = (from p in lstFareInfo
                                                          where p.PTCID == 1
                                                          select p.FareID
                                                 ).FirstOrDefault();
                            objPaxWiseFareId.CHDFareID = (from p in lstFareInfo
                                                          where p.PTCID == 6
                                                          select p.FareID
                                                 ).FirstOrDefault();
                            objPaxWiseFareId.INFFareID = (from p in lstFareInfo
                                                          where p.PTCID == 5
                                                          select p.FareID
                                                 ).FirstOrDefault();
                            objPaxWiseFareId.Cabin = OBCabin;
                            objPaxWiseFareId.EnumFlightType = FlightType.Outbound;
                            colPaxWiseFareIdResult.Add(objPaxWiseFareId);
                            if (isRT)
                            {

                                objPaxWiseFareId = new PaxWiseFareIdResult();
                                var RTdetail = (from p in ViewFareQuoteResult.SegmentDetails
                                                where p.FlightNum == IBflightNo
                                                select new { p.LFID, p.DepartureDate }).FirstOrDefault();
                                //select fare id for ADT

                                FareType[] fareTypesRT = (from p in ViewFareQuoteResult.FlightSegments
                                                          where p.LFID == RTdetail.LFID
                                                          select p.FareTypes
                                                     ).FirstOrDefault();
                                FareInfo[] lstFareInfoRT = (from p in fareTypesRT
                                                            where p.FareTypeName == IBFareType
                                                            select p.FareInfos
                                                           ).FirstOrDefault();
                                objPaxWiseFareId.LFID = RTdetail.LFID;
                                objPaxWiseFareId.origin = destAirportCode;
                                objPaxWiseFareId.destination = originAirportCode;
                                objPaxWiseFareId.DepartureDate = RTdetail.DepartureDate;
                                objPaxWiseFareId.ADTFareID = (from p in lstFareInfoRT
                                                              where p.PTCID == 1
                                                              select p.FareID
                                                     ).FirstOrDefault();
                                objPaxWiseFareId.CHDFareID = (from p in lstFareInfoRT
                                                              where p.PTCID == 6
                                                              select p.FareID
                                                     ).FirstOrDefault();
                                objPaxWiseFareId.INFFareID = (from p in lstFareInfoRT
                                                              where p.PTCID == 5
                                                              select p.FareID
                                                     ).FirstOrDefault();
                                objPaxWiseFareId.Cabin = IBCabin;
                                objPaxWiseFareId.EnumFlightType = FlightType.Inbound;
                                colPaxWiseFareIdResult.Add(objPaxWiseFareId);
                            }

                        }
                        else
                            objPaxWiseFareId.Result = "No result";
                    }
                    else
                    {
                        if (ViewFareQuoteResult.SegmentDetails != null && ViewFareQuoteResult.SegmentDetails.Count() > 0)
                        {
                            var OBDetail = (from p in ViewFareQuoteResult.SegmentDetails
                                            where p.Origin == originAirportCode && p.Destination == destAirportCode
                                            select new { p.LFID, p.DepartureDate }).FirstOrDefault();
                            FareType[] fareTypes = (from p in ViewFareQuoteResult.FlightSegments
                                                    where p.LFID == OBDetail.LFID
                                                    select p.FareTypes
                                                 ).FirstOrDefault();
                            FareInfo[] lstFareInfo = (from p in fareTypes
                                                      where p.FareTypeName == OBFareType
                                                      select p.FareInfos
                                                       ).FirstOrDefault();
                            objPaxWiseFareId.LFID = OBDetail.LFID;
                            objPaxWiseFareId.origin = originAirportCode;
                            objPaxWiseFareId.destination = destAirportCode;
                            objPaxWiseFareId.DepartureDate = OBDetail.DepartureDate;
                            objPaxWiseFareId.ADTFareID = (from p in lstFareInfo
                                                          where p.PTCID == 1
                                                          select p.FareID
                                                 ).FirstOrDefault();
                            objPaxWiseFareId.CHDFareID = (from p in lstFareInfo
                                                          where p.PTCID == 6
                                                          select p.FareID
                                                 ).FirstOrDefault();
                            objPaxWiseFareId.INFFareID = (from p in lstFareInfo
                                                          where p.PTCID == 5
                                                          select p.FareID
                                                 ).FirstOrDefault();
                            objPaxWiseFareId.Cabin = OBCabin;
                            objPaxWiseFareId.EnumFlightType = FlightType.Outbound;
                            colPaxWiseFareIdResult.Add(objPaxWiseFareId);

                            if (isRT)
                            {
                                objPaxWiseFareId = new PaxWiseFareIdResult();
                                var RTDetail = (from p in ViewFareQuoteResult.SegmentDetails
                                                where p.Origin == destAirportCode && p.Destination == originAirportCode
                                                select new { p.LFID, p.DepartureDate }).FirstOrDefault();
                                FareType[] fareTypesRT = (from p in ViewFareQuoteResult.FlightSegments
                                                          where p.LFID == RTDetail.LFID
                                                          select p.FareTypes
                                                     ).FirstOrDefault();
                                FareInfo[] lstFareInfoRT = (from p in fareTypesRT
                                                            where p.FareTypeName == IBFareType
                                                            select p.FareInfos
                                                           ).FirstOrDefault();

                                objPaxWiseFareId.LFID = RTDetail.LFID;
                                objPaxWiseFareId.origin = destAirportCode;
                                objPaxWiseFareId.destination = originAirportCode;
                                objPaxWiseFareId.DepartureDate = RTDetail.DepartureDate;
                                objPaxWiseFareId.ADTFareID = (from p in lstFareInfoRT
                                                              where p.PTCID == 1
                                                              select p.FareID
                                                     ).FirstOrDefault();
                                objPaxWiseFareId.CHDFareID = (from p in lstFareInfoRT
                                                              where p.PTCID == 6
                                                              select p.FareID
                                                     ).FirstOrDefault();
                                objPaxWiseFareId.INFFareID = (from p in lstFareInfoRT
                                                              where p.PTCID == 5
                                                              select p.FareID
                                                     ).FirstOrDefault();
                                objPaxWiseFareId.Cabin = IBCabin;
                                objPaxWiseFareId.EnumFlightType = FlightType.Inbound;
                                colPaxWiseFareIdResult.Add(objPaxWiseFareId);
                            }

                        }
                        else
                            objPaxWiseFareId.Result = "No result";
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;

            }
            return colPaxWiseFareIdResult;
        }
 private int GetFareId(PaxWiseFareIdResult objPaxFare, int PTCID)
 {
     switch (PTCID)
     {
         case 1: return objPaxFare.ADTFareID;
         case 6: return objPaxFare.CHDFareID;
         case 5: return objPaxFare.ADTFareID;
         default: return -1;
     }
 }
        private List<SpecialService> GetSpecialService(FlightRequest objFlightRequest, PaxWiseFareIdResult objPaxWiseFareIdResult, Person person)
        {
            List<SpecialService> colSpecialService = new List<SpecialService>();
            if (person.PTCID != 5)
            {
                //Baggage
                var BaggageRequested = objPaxWiseFareIdResult.EnumFlightType == FlightType.Inbound ? objFlightRequest.InboundBaggage : objFlightRequest.OutboundBaggage;

                if (!String.IsNullOrEmpty(BaggageRequested) && objPaxWiseFareIdResult.Cabin == EnumCabin.Economy.ToString())
                {
                    colSpecialService.Add(new SpecialService()
                    {
                        CodeType = BaggageRequested,
                        ServiceID = -2147483648,
                        SSRCategory = 99,
                        LogicalFlightID = objPaxWiseFareIdResult.LFID,
                        DepartureDate = objPaxWiseFareIdResult.DepartureDate.Date,
                        Amount = (BaggageRequested == "BAGB" ? 50 : (BaggageRequested == "BAGL" ? 100 : 200)),
                        OverrideAmount = false,
                        CurrencyCode = ReservationService.EnumerationsCurrencyCodeTypes.AED,
                        PersonOrgID = person.PersonOrgID,
                        ChargeComment = string.Empty

                    });
                }

                //Meal
                var MealRequested = objPaxWiseFareIdResult.EnumFlightType == FlightType.Inbound ? objFlightRequest.InboundMeal : objFlightRequest.OutboundMeal;
                if (!String.IsNullOrEmpty(MealRequested))
                {

                    colSpecialService.Add(new SpecialService()
                    {
                        CodeType = MealRequested,
                        ServiceID = -2147483648,
                        SSRCategory = 162,
                        LogicalFlightID = objPaxWiseFareIdResult.LFID,
                        DepartureDate = objPaxWiseFareIdResult.DepartureDate.Date,
                        Amount = 50,
                        OverrideAmount = false,
                        CurrencyCode = ReservationService.EnumerationsCurrencyCodeTypes.AED,
                        PersonOrgID = person.PersonOrgID,
                        ChargeComment = string.Empty

                    });
                }

                //IFE
                if (objFlightRequest.IFE && objPaxWiseFareIdResult.Cabin == EnumCabin.Economy.ToString())
                {
                    colSpecialService.Add(new SpecialService()
                    {
                        CodeType = "IFPP",
                        ServiceID = -2147483648,
                        SSRCategory = 141,
                        LogicalFlightID = objPaxWiseFareIdResult.LFID,
                        DepartureDate = objPaxWiseFareIdResult.DepartureDate.Date,
                        Amount = 30,
                        OverrideAmount = false,
                        CurrencyCode = ReservationService.EnumerationsCurrencyCodeTypes.AED,
                        PersonOrgID = person.PersonOrgID,
                        ChargeComment = string.Empty

                    });
                }

            }
            return colSpecialService;
        }
        private List<SpacialServiceAndSeat> GetAvailableSeatForAllLegs(List<SeatsInfo> objSeatsInfo, PaxWiseFareIdResult item, Person person, ref List<AlreadyTakenSeat> AlreadyTakenSeat)
        {
            AlreadyTakenSeat previousSeat = new CreatePNR_AutomationApp.AlreadyTakenSeat();
            List<SpacialServiceAndSeat> colSpecialService = new List<SpacialServiceAndSeat>();
            foreach (var seatinfo in objSeatsInfo.ToArray())
            {
                if (seatinfo.IsCircular && previousSeat != null && previousSeat.PhysicalFlightID > 0 && seatinfo.PhysicalFlightID > 0)
                {
                    SeatCharge seata = new SeatCharge();
                    if (seatinfo.Seat_Charges != null)
                    {
                        seata = (from p in seatinfo.Seat_Charges
                                 where previousSeat.Row == p.RowNumber && previousSeat.SeatNumber == p.Seat
                                 select p).FirstOrDefault();
                    }
                    if (seata != null && seata.RowNumber != 0 && seata.Seat != string.Empty)
                    {
                        colSpecialService.Add(new SpacialServiceAndSeat()
                        {
                            Special_Service = new SpecialService()
                            {
                                CodeType = seata.ServiceCode.Trim(),
                                ServiceID = -2147483648,
                                SSRCategory = 21,
                                LogicalFlightID = item.LFID,
                                DepartureDate = item.DepartureDate.Date,
                                Amount = seata.Amount,
                                OverrideAmount = false,
                                CurrencyCode = ReservationService.EnumerationsCurrencyCodeTypes.AED,
                                PersonOrgID = person.PersonOrgID,
                                ChargeComment = string.Empty
                            },
                            Seat_Charges = seata,
                            PhysicalFlightID = seatinfo.PhysicalFlightID
                        });
                        AlreadyTakenSeat.Add(new AlreadyTakenSeat()
                        {
                            PhysicalFlightID = seatinfo.PhysicalFlightID,
                            Row = seata.RowNumber,
                            SeatNumber = seata.Seat
                        });
                    }
                    else
                    {
                        colSpecialService.Add(new SpacialServiceAndSeat()
                        {
                            Special_Service = new SpecialService()
                            {
                                CodeType = previousSeat.ServiceCode.Trim(),
                                ServiceID = -2147483648,
                                SSRCategory = 21,
                                LogicalFlightID = item.LFID,
                                DepartureDate = item.DepartureDate.Date,
                                Amount = previousSeat.Amount,
                                OverrideAmount = false,
                                CurrencyCode = ReservationService.EnumerationsCurrencyCodeTypes.AED,
                                PersonOrgID = person.PersonOrgID,
                                ChargeComment = string.Empty
                            },
                            Seat_Charges = previousSeat.Seat_Charges,
                            PhysicalFlightID = seatinfo.PhysicalFlightID
                        });
                        AlreadyTakenSeat.Add(new AlreadyTakenSeat()
                        {
                            PhysicalFlightID = seatinfo.PhysicalFlightID,
                            Row = previousSeat.Row,
                            SeatNumber = previousSeat.SeatNumber
                        });
                    }
                }
                else
                {
                    SeatCharge seat = new SeatCharge();
                    List<CreatePNR_AutomationApp.FlightService.SeatAssignment> assignedSeats = seatinfo.Seat_Assignment;
                    if (assignedSeats == null)
                        assignedSeats = new List<FlightService.SeatAssignment>();
                    if (AlreadyTakenSeat != null && AlreadyTakenSeat.Count > 0)
                    {
                        var seatForPhysicalFlight = (from p in AlreadyTakenSeat
                                                     where p.PhysicalFlightID == seatinfo.PhysicalFlightID
                                                     select p).ToList();
                        foreach (var takenitem in seatForPhysicalFlight)
                        {

                            assignedSeats.Add(new FlightService.SeatAssignment()
                            {
                                Seat = takenitem.SeatNumber,
                                RowNumber = takenitem.Row
                            });

                        }

                    }
                    if (assignedSeats != null && assignedSeats.Count > 0)
                    {
                        //seat = (from p in seatinfo.Seat_Charges
                        //        join
                        //            c in assignedSeats on
                        //            new { p.Seat, p.RowNumber } equals new { c.Seat, c.RowNumber }
                        //        where (c.RowNumber != p.RowNumber && c.Seat != p.Seat)
                        //        select p).FirstOrDefault();
                        if (seatinfo.Seat_Charges != null)
                            seat = (from p in seatinfo.Seat_Charges
                                    where !assignedSeats.Any(x => x.RowNumber == p.RowNumber && x.Seat == p.Seat)
                                    select p).FirstOrDefault();

                    }
                    else
                    {
                        if (seatinfo.Seat_Charges != null)
                            seat = (from p in seatinfo.Seat_Charges
                                    select p).FirstOrDefault();
                    }
                    if (seat != null && seat.RowNumber != 0 && seat.Seat != string.Empty)
                    {

                        colSpecialService.Add(new SpacialServiceAndSeat()
                        {
                            Special_Service = new SpecialService()
                            {
                                CodeType = seat.ServiceCode.Trim(),
                                ServiceID = -2147483648,
                                SSRCategory = 21,
                                LogicalFlightID = item.LFID,
                                DepartureDate = item.DepartureDate.Date,
                                Amount = seat.Amount,
                                OverrideAmount = false,
                                CurrencyCode = ReservationService.EnumerationsCurrencyCodeTypes.AED,
                                PersonOrgID = person.PersonOrgID,
                                ChargeComment = string.Empty
                            },
                            Seat_Charges = seat,
                            PhysicalFlightID = seatinfo.PhysicalFlightID
                        });
                        AlreadyTakenSeat.Add(new AlreadyTakenSeat()
                        {
                            PhysicalFlightID = seatinfo.PhysicalFlightID,
                            Row = seat.RowNumber,
                            SeatNumber = seat.Seat
                        });
                        previousSeat.Seat_Charges = seat;
                        previousSeat.ServiceCode = seat.ServiceCode;
                        previousSeat.Amount = seat.Amount;
                        previousSeat.PhysicalFlightID = seatinfo.PhysicalFlightID;
                        previousSeat.Row = seat.RowNumber;
                        previousSeat.SeatNumber = seat.Seat;

                    }
                }
            }
            return colSpecialService;
        }