public override void setUpFlights() { Flight flight = new Flight(); flight.Destination = "London"; flight.FlightTime = new DateTime(2019, 7, 8); flight.FlightCapacity = 10; flight.FlightType = "Cargo"; flight.FlightPrice = 400; AvailableFlights.Add(flight); Flight flight1 = new Flight(); flight1.Destination = "Paris"; flight1.FlightTime = new DateTime(2019, 7, 9); flight.FlightCapacity = 20; flight.FlightType = "Cargo"; flight.FlightPrice = 400; AvailableFlights.Add(flight1); Flight flight2 = new Flight(); flight.Destination = "Pyongyang"; flight2.FlightTime = new DateTime(2019, 7, 10); flight2.FlightCapacity = 100; flight.FlightType = "Cargo"; flight2.FlightPrice = 200; }
public override void setUpFlights() { Flight flight = new Flight(); flight.Destination = "London"; flight.FlightTime = new DateTime(2019, 7, 8); flight.FlightCapacity = 10; flight.FlightType = "Passenger"; flight.FlightPrice = 400; AvailableFlights.Add(flight); Flight flight1 = new Flight(); flight1.Destination = "Paris"; flight1.FlightTime = new DateTime(2019, 7, 9); flight1.FlightCapacity = 20; flight1.FlightType = "Passenger"; flight1.FlightPrice = 500; AvailableFlights.Add(flight1); Flight flight2 = new Flight(); flight2.Destination = "Stockholm"; flight2.FlightTime = new DateTime(2019, 7, 10); flight2.FlightCapacity = 2; flight2.FlightType = "Passenger"; flight2.FlightPrice = 200; AvailableFlights.Add(flight2); Flight flight3 = new Flight(); flight3.Destination = "Pyongyang"; flight3.FlightTime = new DateTime(2019, 7, 10); flight3.FlightCapacity = 100; flight3.FlightType = "Passenger"; flight3.FlightPrice = 700; AvailableFlights.Add(flight3); }
/// <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. } }
public List <AvailableFlights> GetAllAvailableFlights(DateTime FromDate, DateTime ToDate, int Pax) { if (FromDate < DateTime.Now.Date || FromDate == DateTime.MinValue) { throw new ArgumentException($"Invalid start date {FromDate}", nameof(FromDate)); } if (ToDate < DateTime.Now.Date || FromDate == DateTime.MinValue) { throw new ArgumentException($"Invalid end date {ToDate}", nameof(ToDate)); } if (Pax < 1) { throw new ArgumentException($"Passenger count has to be atleast 1 { Pax }", nameof(Pax)); } var Bookings = _flightsDataBase.GetBookings(); var Flights = _flightsDataBase.GetFlights(); var AvailableFlights = new List <AvailableFlights>(); var DateList = new List <DateTime>(); for (DateTime date = FromDate.Date; date.Date <= ToDate.Date; date = date.AddDays(1)) { DateList.Add(date); foreach (var t in Flights) { AvailableFlights.Add(new AvailableFlights { Date = date.Date, Flights = t }); } } var Modified_AvailableFlights = new List <AvailableFlights>(); foreach (var AvFlights in AvailableFlights) { var M_Avl_Flights = new AvailableFlights(); var M_Flight = new Flight(); var ts = GetBooking(AvFlights.Date.Date, AvFlights.Flights.Id); var originalcapacity = Flights .Where(o => o.Id == AvFlights.Flights.Id) .Select(u => u.Capacity) .FirstOrDefault(); M_Flight.Id = AvFlights.Flights.Id; M_Flight.FlightNumber = AvFlights.Flights.FlightNumber; M_Flight.ArrivalCity = AvFlights.Flights.ArrivalCity; M_Flight.DepartureCity = AvFlights.Flights.DepartureCity; M_Flight.startTime = AvFlights.Flights.startTime; M_Flight.EndTime = AvFlights.Flights.EndTime; M_Flight.Capacity = (originalcapacity - ts); M_Avl_Flights.Date = AvFlights.Date; M_Avl_Flights.Flights = M_Flight; Modified_AvailableFlights.Add(M_Avl_Flights); } return(Modified_AvailableFlights .Where(v => (v.Flights.Capacity - Pax) >= 0).ToList()); }
public override void RegisterAFlight(Flight flight) { AvailableFlights.Add(flight); }
public override Flight checkFlightAvailability(string destination, DateTime flightTime) { List <Flight> availableFlight = AvailableFlights.FindAll(x => x.Destination == destination); return(availableFlight.Count > 0 ? availableFlight.First() : null); }