private void LoadFlights(IDatabaseContext stubDB)
        {
            //first flight
            var dt1        = new DateTime(2020, 1, 1, 10, 00, 00, DateTimeKind.Utc); //2020-01-01T10:00:00Z
            var initialLoc = new InitialFlightLocation();

            initialLoc.Longitude = 20;
            initialLoc.Latitude  = 20;
            initialLoc.DateTime  = dt1;
            var seg = new FlightSegment();

            seg.Latitude        = 24;
            seg.Longitude       = 24;
            seg.TimespanSeconds = 3600; //one hour later
            var segments = new List <FlightSegment>();

            segments.Add(seg);
            var f1 = new FlightPlan();

            f1.FlightId        = "1";
            f1.CompanyName     = "1";
            f1.Passengers      = 1;
            f1.InitialLocation = initialLoc;
            f1.Segments        = segments;
            stubDB.AddFlightPlan(f1);

            //second flight
            dt1                  = new DateTime(2020, 1, 1, 10, 15, 00, DateTimeKind.Utc); //2020-01-01T10:15:00Z
            initialLoc           = new InitialFlightLocation();
            initialLoc.Longitude = 30;
            initialLoc.Latitude  = 30;
            initialLoc.DateTime  = dt1;
            segments             = new List <FlightSegment>();
            var seg1 = new FlightSegment();

            seg1.Latitude        = 31;
            seg1.Longitude       = 31;
            seg1.TimespanSeconds = 900; //15 minites later
            segments.Add(seg1);
            var seg2 = new FlightSegment();

            seg2.Latitude        = 32;
            seg2.Longitude       = 32;
            seg2.TimespanSeconds = 900; //15 minites later
            segments.Add(seg2);
            var f2 = new FlightPlan();

            f2.FlightId        = "2";
            f2.CompanyName     = "2";
            f2.Passengers      = 2;
            f2.InitialLocation = initialLoc;
            f2.Segments        = segments;
            stubDB.AddFlightPlan(f2);
        }
        public ActionResult SearchFlight(FlightSegment collection)
        {
            try
            {
                //This api is configured from appsettings.json

                var client  = new RestClient(APIConstatnt.Api);
                var request = new RestRequest(Method.POST);
                request.RequestFormat = DataFormat.Json;
                _ = request.AddBody(new FlightSegmentDto
                {
                    Destination = collection.Destination,
                    OnwardDate  = collection.OnwardDate,
                    Origin      = collection.Origin,
                    ReturnDate  = collection.ReturnDate
                });
                var     response = client.Execute(request);
                dynamic materialSerializedObject = JsonConvert.DeserializeObject(response.Content);
                var     materialData             = (Dictionary <string, List <object> >)JsonConvert.DeserializeObject <Dictionary <string, List <object> > >(JsonConvert.SerializeObject(materialSerializedObject));
                foreach (var item in materialData)
                {
                    if (item.Key.Equals("flightDetails"))
                    {
                        foreach (dynamic data in item.Value)
                        {
                            var serlizedData = (Dictionary <string, List <FlightSegment> >)JsonConvert.DeserializeObject <Dictionary <string, List <FlightSegment> > >(JsonConvert.SerializeObject(data));
                            foreach (var items in serlizedData.Values)
                            {
                                ListOfFlightSegment.AddRange(items);
                            }
                        }
                    }
                }

                return(RedirectToAction(nameof(Details)));
            }
            catch
            {
                return(View());
            }
        }
Example #3
0
        public ActionResult InterpretarRespuesta(dynamic respuesta)
        {
            var     data      = respuesta[0];
            JObject resultado = JObject.Parse(data);

            IList <JToken> results = resultado["OriginDestinationInformation"].Children().ToList();
            List <OriginDestinationInformation> InformationList = new List <OriginDestinationInformation>();

            foreach (JToken result in results)
            {
                OriginDestinationInformation Information = new OriginDestinationInformation();
                //Llenar ida y vuelta
                IList <JToken> opcionesVuelo = result["OriginDestinationOptions"].Children().ToList();
                foreach (var opcion in opcionesVuelo)
                {
                    if (opcion.Path.Contains("OriginDestinationOptions.OriginDestinationOption"))
                    {
                        OriginDestinationOption ListadoOpcionVuelo     = new OriginDestinationOption();
                        List <FlightSegment>    ListadoSegmentosVuelos = new List <FlightSegment>();
                        Information.DepartureDateTime   = result["DepartureDateTime"].ToString();
                        Information.OriginLocation      = result["OriginLocation"].ToString();
                        Information.DestinationLocation = result["DestinationLocation"].ToString();

                        dynamic segmentos = opcion.ToList();
                        //varios segmentos de vuelo
                        for (int v = 0; v < segmentos[0].Count; v++)
                        {
                            var nivelsuperior = segmentos[0];
                            var vuelo         = nivelsuperior[v]["FlightSegment"];
                            int i             = 0;
                            List <BookingClassAvail> BookingClassAvailList = new List <BookingClassAvail>();
                            var DepartureDateTime = string.Empty;
                            var ArrivalDateTime   = string.Empty;
                            var StopQuantity      = string.Empty;
                            var FlightNumber      = string.Empty;
                            var JourneyDuration   = string.Empty;
                            var DepartureAirport  = string.Empty;
                            var ArrivalAirport    = string.Empty;
                            var Equipment         = string.Empty;
                            var MarketingAirline  = string.Empty;
                            var Meal      = string.Empty;
                            var RPH       = string.Empty;
                            var CabinType = string.Empty;
                            foreach (var item in vuelo)
                            {
                                if (i == 0)//Datos del vuelo
                                {
                                    DepartureDateTime = item.First["DepartureDateTime"].Value;
                                    ArrivalDateTime   = item.First["ArrivalDateTime"].Value;
                                    StopQuantity      = item.First["StopQuantity"].Value;
                                    FlightNumber      = item.First["FlightNumber"].Value;
                                    JourneyDuration   = item.First["JourneyDuration"].Value;
                                }
                                if (i == 1)
                                {
                                    var nivel1 = item.First["@attributes"];
                                    DepartureAirport = nivel1["LocationCode"].Value;
                                }
                                if (i == 2)
                                {
                                    var nivel1 = item.First["@attributes"];
                                    ArrivalAirport = nivel1["LocationCode"].Value;
                                }
                                if (i == 3)
                                {
                                    var nivel1 = item.First["@attributes"];
                                    Equipment = nivel1["AirEquipType"].Value;
                                }
                                if (i == 4)
                                {
                                    var nivel1 = item.First["@attributes"];
                                    MarketingAirline = nivel1["CompanyShortName"].Value;
                                }
                                if (i == 5)
                                {
                                    var nivel1 = item.First["@attributes"];
                                    Meal = nivel1["MealCode"].Value;
                                }
                                if (i == 6)
                                {
                                    var nivel1 = item.First["@attributes"];
                                    CabinType = nivel1["CabinType"].Value;
                                    RPH       = nivel1["RPH"].Value;
                                }
                                if (i == 7)
                                {
                                    for (int x = 0; x < item.First.Count; x++)
                                    {
                                        var nivel1                          = item.First;
                                        var nivel2                          = nivel1[x]["@attributes"];
                                        var ResBookDesigCode                = nivel2["ResBookDesigCode"].Value;
                                        var ResBookDesigQuantity            = nivel2["ResBookDesigQuantity"].Value;
                                        var RPHBooking                      = nivel2["RPH"].Value;
                                        BookingClassAvail bookingClassAvail = new BookingClassAvail
                                        {
                                            ResBookDesigCode     = ResBookDesigCode,
                                            ResBookDesigQuantity = ResBookDesigQuantity,
                                            RPHBooking           = RPHBooking
                                        };
                                        BookingClassAvailList.Add(bookingClassAvail);
                                    }
                                }
                                i++;
                            }
                            FlightSegment nuevoSegmento = new FlightSegment
                            {
                                DepartureDateTime = DepartureDateTime,
                                ArrivalDateTime   = ArrivalDateTime,
                                StopQuantity      = StopQuantity,
                                FlightNumber      = FlightNumber,
                                JourneyDuration   = JourneyDuration,
                                DepartureAirport  = DepartureAirport,
                                ArrivalAirport    = ArrivalAirport,
                                Equipment         = Equipment,
                                MarketingAirline  = MarketingAirline,
                                Meal                  = Meal,
                                RPH                   = RPH,
                                CabinType             = CabinType,
                                BookingClassAvailList = BookingClassAvailList
                            };
                            ListadoSegmentosVuelos.Add(nuevoSegmento);
                        }


                        ListadoOpcionVuelo.ListFlightSegment = ListadoSegmentosVuelos;
                        Information.OriginDestinationOptions = ListadoOpcionVuelo;
                        InformationList.Add(Information);
                    }
                    else
                    {
                        Information.DepartureDateTime        = result["DepartureDateTime"].ToString();
                        Information.OriginLocation           = result["OriginLocation"].ToString();
                        Information.DestinationLocation      = result["DestinationLocation"].ToString();
                        Information.OriginDestinationOptions = null;
                        InformationList.Add(Information);
                    }
                }
            }
            return(Json(InformationList));
        }
        /// <summary>
        /// Get the flights avalibility response and assigning the values to the params 
        /// </summary>
        /// <param name="xmlRequestData"></param>
        /// <returns></returns>
        public FlightsAvailabilityResponse GetAvailableFlights(String xmlRequestData)
        {
            FlightsAvailabilityResponse objFlightsAvailabilityResponse = new FlightsAvailabilityResponse();
            AvailableFlights objAvailableFlights = null;
            try
            {
                string result = objFlights.GetAvailabilityfn(xmlRequestData);
                BookingClass objBookingClass = null;
                BookingClassFare objBookingClassFare = null;
                ChargeableFares objChargeableFares = null;
                FareDetails objFareDetails = null;
                FlightSegment objFlightSegment = null;
                FlightSegments objFlightSegments = null;
                NonchargeableFares objNonchargeableFares = null;
                OriginDestinationoptionId objOriginDestinationoptionId = null;

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(result);
                XmlNodeList xmlNodes = doc.SelectNodes("//Response__Depart/OriginDestinationOptions/OriginDestinationOption");

                foreach (XmlNode node in xmlNodes)
                {
                    objAvailableFlights = new AvailableFlights();
                    objChargeableFares = new ChargeableFares();
                    objNonchargeableFares = new NonchargeableFares();
                    objFareDetails = new FareDetails();
                    objOriginDestinationoptionId=new OriginDestinationoptionId();

                    //ChargeableFares
                    objChargeableFares.ActualBaseFare = double.Parse(node["FareDetails"]["ChargeableFares"]["ActualBaseFare"].InnerXml);
                    objChargeableFares.Tax = double.Parse(node["FareDetails"]["ChargeableFares"]["Tax"].InnerXml);
                    objChargeableFares.STax = double.Parse(node["FareDetails"]["ChargeableFares"]["STax"].InnerXml);
                    objChargeableFares.SCharge = double.Parse(node["FareDetails"]["ChargeableFares"]["SCharge"].InnerXml);
                    objChargeableFares.TDiscount = double.Parse(node["FareDetails"]["ChargeableFares"]["TDiscount"].InnerXml);
                    objChargeableFares.TPartnerCommission = double.Parse(node["FareDetails"]["ChargeableFares"]["TPartnerCommission"].InnerXml);
                    objFareDetails.ChargeableFares = objChargeableFares;

                    //Non ChargeableFares
                    objNonchargeableFares.TCharge = double.Parse(node["FareDetails"]["NonchargeableFares"]["TCharge"].InnerXml);
                    objNonchargeableFares.TMarkup = double.Parse(node["FareDetails"]["NonchargeableFares"]["TMarkup"].InnerXml);
                    objNonchargeableFares.TSdiscount = double.Parse(node["FareDetails"]["NonchargeableFares"]["TSdiscount"].InnerXml);
                    objFareDetails.NonchargeableFares = objNonchargeableFares;

                    objFlightSegments = new FlightSegments();

                    foreach (XmlNode childnode in node["FlightSegments"].ChildNodes)
                    {
                        objFlightSegment = new FlightSegment();
                        //Flight Segment
                        objFlightSegment.AirEquipType = childnode["AirEquipType"].InnerXml;
                        objFlightSegment.ArrivalAirportCode = childnode["ArrivalAirportCode"].InnerXml;
                        objFlightSegment.ArrivalDateTime = Convert.ToDateTime(childnode["ArrivalDateTime"].InnerXml);
                        objFlightSegment.DepartureAirportCode = childnode["DepartureAirportCode"].InnerXml;
                        objFlightSegment.DepartureDateTime = Convert.ToDateTime(childnode["DepartureDateTime"].InnerXml);
                        objFlightSegment.FlightNumber = childnode["FlightNumber"].InnerXml;
                        objFlightSegment.OperatingAirlineCode = childnode["OperatingAirlineCode"].InnerXml;
                        objFlightSegment.OperatingAirlineFlightNumber = childnode["OperatingAirlineFlightNumber"].InnerXml;
                        objFlightSegment.RPH = childnode["RPH"].InnerXml;
                        objFlightSegment.StopQuantity = childnode["StopQuantity"].InnerXml;
                        objFlightSegment.airLineName = childnode["airLineName"].InnerXml;
                        objFlightSegment.airportTax = childnode["airportTax"].InnerXml;
                        objFlightSegment.imageFileName = childnode["imageFileName"].InnerXml;
                        objFlightSegment.viaFlight = childnode["viaFlight"].InnerXml;
                        objFlightSegment.Discount = childnode["Discount"].InnerXml;
                        objFlightSegment.airportTaxChild = childnode["airportTaxChild"].InnerXml;
                        objFlightSegment.airportTaxInfant = childnode["airportTaxInfant"].InnerXml;
                        objFlightSegment.adultTaxBreakup = childnode["adultTaxBreakup"].InnerXml;
                        objFlightSegment.childTaxBreakup = childnode["childTaxBreakup"].InnerXml;
                        objFlightSegment.infantTaxBreakup = childnode["infantTaxBreakup"].InnerXml;
                        objFlightSegment.octax = childnode["octax"].InnerXml;
                        //BookingClass
                        objBookingClass = new BookingClass();
                        objBookingClass.Availability = childnode["BookingClass"]["Availability"].InnerXml;
                        objBookingClass.ResBookDesigCode = childnode["BookingClass"]["ResBookDesigCode"].InnerXml;
                        objFlightSegment.BookingClass = objBookingClass;

                        //BookingClassFare
                        objBookingClassFare = new BookingClassFare();
                        objBookingClassFare.adultFare = childnode["BookingClassFare"]["adultFare"].InnerXml;
                        objBookingClassFare.bookingclass = childnode["BookingClassFare"]["bookingclass"].InnerXml;
                        objBookingClassFare.classType = childnode["BookingClassFare"]["classType"].InnerXml;
                        objBookingClassFare.farebasiscode = childnode["BookingClassFare"]["farebasiscode"].InnerXml;
                        objBookingClassFare.Rule = childnode["BookingClassFare"]["Rule"].InnerXml;
                        objBookingClassFare.adultCommission = childnode["BookingClassFare"]["adultCommission"].InnerXml;
                        objBookingClassFare.childCommission = childnode["BookingClassFare"]["childCommission"].InnerXml;
                        objBookingClassFare.commissionOnTCharge = childnode["BookingClassFare"]["commissionOnTCharge"].InnerXml;
                        objFlightSegment.BookingClassFare = objBookingClassFare;

                        objFlightSegments.Add(objFlightSegment);
                    }

                    //OrigindestinationOptionId
                    objOriginDestinationoptionId.id = node["id"].InnerXml;
                    objOriginDestinationoptionId.key = node["key"].InnerXml;

                    objAvailableFlights.FareDetails = objFareDetails;
                    objAvailableFlights.FlightSegments = objFlightSegments;
                    objAvailableFlights.OriginDestinationoptionId = objOriginDestinationoptionId;
                    objFlightsAvailabilityResponse.Add(objAvailableFlights);
                }
            }
            catch (Exception ex)
            {
            }
            return objFlightsAvailabilityResponse;

            List<AvailableFlights> AvailableFlights = objFlightsAvailabilityResponse.Where(e => e.FlightSegments.Count > 1).ToList();
            foreach (AvailableFlights item in AvailableFlights)
            {
               // item.FlightSegments.
            }
        }
Example #5
0
        public int Insert(Repo.Models.Flights.Flight model, string origin, string destionation, string departureDate, string returnDate = null, string currency = Default.CURRENCY, int adults = Default.ADULTS)
        {
            if (model == null || String.IsNullOrEmpty(origin) || String.IsNullOrEmpty(destionation) || String.IsNullOrEmpty(departureDate))
            {
                throw new ArgumentNullException();
            }

            if (model.Data == null || model.Dictionaries == null || model.Meta == null)
            {
                throw new NullReferenceException();
            }

            if (model.Dictionaries.Currencies != null)
            {
                foreach (var item in model.Dictionaries.Currencies)
                {
                    if (unitOfWork.Currencies.FindByCode(item.Key) == null)
                    {
                        unitOfWork.Currencies.Insert(item);
                    }
                }
            }

            if (model.Dictionaries.Aircraft != null)
            {
                foreach (var item in model.Dictionaries.Aircraft)
                {
                    if (unitOfWork.Aircrafts.FindByCode(item.Key) == null)
                    {
                        unitOfWork.Aircrafts.Insert(item);
                    }
                }
            }

            if (model.Dictionaries.Carriers != null)
            {
                foreach (var item in model.Dictionaries.Carriers)
                {
                    if (unitOfWork.Carriers.FindByCode(item.Key) == null)
                    {
                        unitOfWork.Carriers.Insert(item);
                    }
                }
            }

            if (model.Dictionaries.Locations != null)
            {
                foreach (var item in model.Dictionaries.Locations)
                {
                    if (unitOfWork.Locations.FindByCode(item.Key) == null)
                    {
                        unitOfWork.Locations.Insert(new KeyValuePair <string, string>(item.Key, item.Value.detailedName));
                    }
                }
            }


            Flight flight = new Flight()
            {
                Adults        = adults,
                CurrencyId    = unitOfWork.Currencies.FindByCode(model.Meta.Currency).CurrencyId,
                Origin        = origin,
                Destination   = destionation,
                DepartureDate = DateTime.Parse(departureDate),
                ReturnDate    = DateTime.Parse(returnDate ?? DateTime.MinValue.ToString()),
                Link          = model.Meta.Links.Self,
            };

            flight.FlightId = unitOfWork.Flights.Insert(flight);

            try
            {
                foreach (var item in model.Data)
                {
                    FlightOffer flightOffer = new FlightOffer
                    {
                        Id       = item.Id,
                        Type     = item.Type,
                        FlightId = flight.FlightId,
                    };

                    var flightOfferId = unitOfWork.FlightOffers.Insert(flightOffer);
                    foreach (var offer in item.OfferItems)
                    {
                        OfferItem offerItem = new OfferItem();
                        offerItem.FlightOfferId = flightOfferId;

                        Price price = new Price
                        {
                            Total      = offer.Price.Total,
                            TotalTaxes = offer.Price.TotalTaxes,
                        };
                        offerItem.PriceId = unitOfWork.Prices.Insert(price);

                        if (offer.PricePerAdult != null)
                        {
                            Price adult = new Price
                            {
                                Total      = offer.PricePerAdult.Total,
                                TotalTaxes = offer.PricePerAdult.TotalTaxes,
                            };
                            offerItem.PricePerAdultId = unitOfWork.Prices.Insert(adult);
                        }

                        if (offer.PricePerChild != null)
                        {
                            Price child = new Price
                            {
                                Total      = offer.PricePerChild.Total,
                                TotalTaxes = offer.PricePerChild.TotalTaxes,
                            };
                            offerItem.PricePerChildId = unitOfWork.Prices.Insert(child);
                        }

                        if (offer.PricePerInfant != null)
                        {
                            Price infant = new Price
                            {
                                Total      = offer.PricePerInfant.Total,
                                TotalTaxes = offer.PricePerInfant.TotalTaxes,
                            };
                            offerItem.PricePerInfantId = unitOfWork.Prices.Insert(infant);
                        }

                        if (offer.PricePerSenior != null)
                        {
                            Price senior = new Price
                            {
                                Total      = offer.PricePerSenior.Total,
                                TotalTaxes = offer.PricePerSenior.TotalTaxes,
                            };
                            offerItem.PricePerSeniorId = unitOfWork.Prices.Insert(senior);
                        }

                        var offerItemId = unitOfWork.OfferItems.Insert(offerItem);
                        foreach (var ser in offer.Services)
                        {
                            Data.Flights.Service service = new Data.Flights.Service();
                            service.OfferItemId = offerItemId;

                            var serviceId = unitOfWork.Services.Insert(service);
                            if (ser.Segments != null)
                            {
                                foreach (var seg in ser.Segments)
                                {
                                    Segment segment = new Segment();
                                    segment.ServiceId = serviceId;

                                    FlightSegment flightSegment = new FlightSegment();
                                    flightSegment.AircraftId = unitOfWork.Aircrafts.FindByCode(seg.FlightSegment.Aircraft.Code).AircraftId;

                                    FlightEndPoint arrival = new FlightEndPoint
                                    {
                                        At         = seg.FlightSegment.Arrival.At,
                                        LocationId = unitOfWork.Locations.FindByCode(seg.FlightSegment.Arrival.IataCode).LocationId,
                                        Terminal   = seg.FlightSegment.Arrival.Terminal,
                                    };
                                    flightSegment.ArrivalId = unitOfWork.FlightEndPoints.Insert(arrival);
                                    flightSegment.CarrierId = unitOfWork.Carriers.FindByCode(seg.FlightSegment.CarrierCode).CarrierId;

                                    FlightEndPoint departure = new FlightEndPoint
                                    {
                                        At         = seg.FlightSegment.Departure.At,
                                        LocationId = unitOfWork.Locations.FindByCode(seg.FlightSegment.Departure.IataCode).LocationId,
                                        Terminal   = seg.FlightSegment.Departure.Terminal,
                                    };
                                    flightSegment.DepartureId = unitOfWork.FlightEndPoints.Insert(departure);
                                    flightSegment.Duration    = seg.FlightSegment.Duration;
                                    flightSegment.Number      = seg.FlightSegment.Number;

                                    Operation operation = new Operation
                                    {
                                        CarrierId = unitOfWork.Carriers.FindByCode(seg.FlightSegment.Operating.CarrierCode).CarrierId,
                                        Number    = seg.FlightSegment.Operating.Number,
                                    };
                                    flightSegment.OperationId = unitOfWork.Operations.Insert(operation);

                                    segment.FlightSegmentId = unitOfWork.FlightSegments.Insert(flightSegment);

                                    if (seg.FlightSegment.Stops != null)
                                    {
                                        foreach (var stop in seg.FlightSegment.Stops)
                                        {
                                            FlightStop flightStop = new FlightStop
                                            {
                                                AircraftId      = unitOfWork.Aircrafts.FindByCode(stop.NewAircraft.Code).AircraftId,
                                                ArrivalAt       = stop.ArrivalAt,
                                                CarrierId       = unitOfWork.Carriers.FindByCode(stop.IataCode).CarrierId,
                                                DepartureAt     = stop.DepartureAt,
                                                Duration        = stop.Duration,
                                                FlightSegmentId = segment.FlightSegmentId,
                                            };
                                            unitOfWork.FlightStops.Insert(flightStop);
                                        }
                                    }

                                    if (seg.PricingDetailPerAdult != null)
                                    {
                                        PricingDetail adult = new PricingDetail
                                        {
                                            Availability = seg.PricingDetailPerAdult.Availability,
                                            FareBasis    = seg.PricingDetailPerAdult.FareBasis,
                                            FareClass    = seg.PricingDetailPerAdult.FareClass,
                                            TravelClass  = seg.PricingDetailPerAdult.TravelClass,
                                        };
                                        segment.PricingDetailPerAdultId = unitOfWork.PricingDetails.Insert(adult);
                                    }

                                    if (seg.PricingDetailPerChild != null)
                                    {
                                        PricingDetail child = new PricingDetail
                                        {
                                            Availability = seg.PricingDetailPerChild.Availability,
                                            FareBasis    = seg.PricingDetailPerChild.FareBasis,
                                            FareClass    = seg.PricingDetailPerChild.FareClass,
                                            TravelClass  = seg.PricingDetailPerChild.TravelClass,
                                        };
                                        segment.PricingDetailPerChildId = unitOfWork.PricingDetails.Insert(child);
                                    }

                                    if (seg.PricingDetailPerInfant != null)
                                    {
                                        PricingDetail infant = new PricingDetail
                                        {
                                            Availability = seg.PricingDetailPerInfant.Availability,
                                            FareBasis    = seg.PricingDetailPerInfant.FareBasis,
                                            FareClass    = seg.PricingDetailPerInfant.FareClass,
                                            TravelClass  = seg.PricingDetailPerInfant.TravelClass,
                                        };
                                        segment.PricingDetailPerInfantId = unitOfWork.PricingDetails.Insert(infant);
                                    }

                                    if (seg.PricingDetailPerSenior != null)
                                    {
                                        PricingDetail senior = new PricingDetail
                                        {
                                            Availability = seg.PricingDetailPerSenior.Availability,
                                            FareBasis    = seg.PricingDetailPerSenior.FareBasis,
                                            FareClass    = seg.PricingDetailPerSenior.FareClass,
                                            TravelClass  = seg.PricingDetailPerSenior.TravelClass,
                                        };
                                        segment.PricingDetailPerSeniorId = unitOfWork.PricingDetails.Insert(senior);
                                    }

                                    var segmentId = unitOfWork.Segments.Insert(segment);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }

            return(flight.FlightId);
        }