public ActionResult AirportList() { AirportDetails AirportDetailsObj = new AirportDetails(); AirportDetailsObj = _AirportDataRepository.GetAirportDetails(_ServiceHelperRepository); _CacheRepository.Set <AirportDetails>(Constants.Constants.Airport, AirportDetailsObj); return(View(AirportDetailsObj)); }
/// <summary> /// Returns Airport Detaisl Objecdt which contains both List of Airports and Countries /// </summary> /// <returns></returns> public AirportDetails GetAirportDetails(IServiceHelperRepository _ServiceHelperRepository) { List <Airport> AirportListObj = Helpers.JsonData(_ServiceHelperRepository); AirportDetails AirportDetailsObj = new AirportDetails(); AirportDetailsObj = GetAirportData(AirportListObj, _ServiceHelperRepository); return(AirportDetailsObj); }
/// <summary> /// Get Distance between Source and Destination Airports /// </summary> /// <param name="AirportData"></param> /// <param name="Source"></param> /// <param name="Destination"></param> /// <returns></returns> public double GetDistance(AirportDetails AirportData, string Source, string Destination) { var SourceCity = AirportData.AirportDetailsList.Where(x => x.name != null && x.name.ToLower().Equals(Source.ToLower())).ToList().First(); var DestinationCity = AirportData.AirportDetailsList.Where(x => x.name != null && x.name.ToLower().Equals(Destination.ToLower())).ToList().First(); var sCoord = new GeoCoordinate(Convert.ToDouble(SourceCity.lat), Convert.ToDouble(SourceCity.lon)); var eCoord = new GeoCoordinate(Convert.ToDouble(DestinationCity.lat), Convert.ToDouble(DestinationCity.lon)); return(sCoord.GetDistanceTo(eCoord) / 1000); }
/// <summary> /// Get the list of Airport Data available in European Countries /// </summary> /// <param name="AirportListObj"></param> /// <param name="_ServiceHelperRepository"></param> /// <returns></returns> public AirportDetails GetAirportData(List <Airport> AirportListObj, IServiceHelperRepository _ServiceHelperRepository) { var EuropeanCities = AirportListObj.Where(x => x.continent.ToLower().Equals(Constants.Constants.EU) && x.continent.Length > 0 && x.status != 0).ToList(); HashSet <string> countrySet = new HashSet <string>(EuropeanCities.Select(x => x.iso).ToList()); AirportDetails AirportDetailsObj = new AirportDetails(); AirportDetailsObj.AirportDetailsList = EuropeanCities; AirportDetailsObj.CountryList = _ServiceHelperRepository.GetCountryStream(countrySet); return(AirportDetailsObj); }
public IActionResult Create([Bind("Iata,Longitude,Iso,Status,Name,Continent,Type,Latitude,Size")] AirportDetails airportDetails) { var status = _airportConnector.addAirportinDatabase(airportDetails); if (!status) { ViewBag.result = ErrorMessage; return(this.View("~/Views/Home/Create.cshtml")); } ModelState.Clear(); ViewBag.result = SuccessMessage; return(this.View("~/Views/Home/Create.cshtml")); }
public bool addAirportinDatabase(AirportDetails airportDetails) { _cache.Remove(cacheKey); if (airportDetails.Continent.ToUpper().Equals(euContient)) { _airportRepository.AddAsync(airportDetails); return(true); } else { return(false); } }
public ActionResult CalculateDistance(string Source, string Destination) { var AirportData = _CacheRepository.Get <AirportDetails>(Constants.Constants.Airport); if (AirportData == null) { AirportDetails AirportDetailsObj = new AirportDetails(); AirportDetailsObj = _AirportDataRepository.GetAirportDetails(_ServiceHelperRepository); AirportData = AirportDetailsObj; _CacheRepository.Set <AirportDetails>(Constants.Constants.Airport, AirportDetailsObj); } var Distance = _GeoLocationRepository.GetDistance(AirportData, Source, Destination); return(Json(new { DistanceBetween = Math.Round(Distance, 2) })); }
public ActionResult AirportListBasedOnCountrySelection(string ISO) { var AirportData = _CacheRepository.Get <AirportDetails>(Constants.Constants.Airport); if (AirportData == null) { AirportDetails AirportDetailsObject = new AirportDetails(); AirportDetailsObject = _AirportDataRepository.GetAirportDetails(_ServiceHelperRepository); AirportData = AirportDetailsObject; _CacheRepository.Set <AirportDetails>(Constants.Constants.Airport, AirportDetailsObject); } var AirportsInCountries = AirportData.AirportDetailsList.Where(x => x.name != null && x.iso.ToLower().Equals(ISO.ToLower())).ToList(); AirportDetails AirportDetailsObj = new AirportDetails(); AirportDetailsObj.AirportDetailsList = AirportsInCountries; return(PartialView(AirportDetailsObj)); }
public async Task AddAsync(AirportDetails europeAirport) { _dbContext.AirportDetails.Add(europeAirport); await _dbContext.SaveChangesAsync(); }
static void Main(string[] args) { // // PING REQUEST // String payload = "this my payload; there are many like it but this one is mine"; String someTraceId = "doesntmatter-8176"; String originApp = "UAPI"; //set up the request parameters into a PingReq object PingReq req = new PingReq(); req.Payload = payload; req.TraceId = someTraceId; ConsoleApplication1.SystemService.BillingPointOfSaleInfo billSetInfo = new ConsoleApplication1.SystemService.BillingPointOfSaleInfo(); billSetInfo.OriginApplication = originApp; req.BillingPointOfSaleInfo = billSetInfo; req.TargetBranch = CommonUtility.GetConfigValue(ProjectConstants.G_TARGET_BRANCH); Console.WriteLine(req); try { //run the ping request //WSDLService.sysPing.showXML(true); SystemPingPortTypeClient client = new SystemPingPortTypeClient("SystemPingPort", WsdlService.SYSTEM_ENDPOINT); //Console.WriteLine(client.Endpoint); client.ClientCredentials.UserName.UserName = Helper.RetrunUsername(); client.ClientCredentials.UserName.Password = Helper.ReturnPassword(); /*var httpHeaders = new Dictionary<string, string>(); * httpHeaders.Add("Username", "travelportsuperadmin"); * httpHeaders.Add("Password", "abc123"); * client.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders));*/ /*HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty(); * httpRequestProperty.Headers[HttpRequestHeader.Authorization] = "Basic " + * Convert.ToBase64String(Encoding.ASCII.GetBytes(client.ClientCredentials.UserName.UserName + * ":" + client.ClientCredentials.UserName.Password)); * * using (OperationContextScope scope = new OperationContextScope(client.InnerChannel)) * { * OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = * httpRequestProperty; * return client.processRequest(castRequest) as TSRsp; * } * * * OperationContext.Current.OutgoingMessageProperties*/ var httpHeaders = Helper.ReturnHttpHeader(); client.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders)); PingRsp rsp = client.service(req); //print results.. payload and trace ID are echoed back in response Console.WriteLine(rsp.Payload); //Console.WriteLine(rsp.TraceId); //Console.WriteLine(rsp.TransactionId); AirportDetails airports = new AirportDetails(); //Here we are getting the list of airports, we can use it anyway we want IDictionary <String, String> airportsList = airports.AllAirportsList(); //Here we are getting the list of airports in a particular city, we are harcoding the city as New York here IDictionary <String, String> airportInCityList = airports.GetAllAiportsFromParticualrCity("New York"); AirSvcTest airTest = new AirSvcTest(); airTest.Availability(); AirLFSTest lfsTest = new AirLFSTest(); Boolean solutionResult = false; //Change it to true if you want AirPricingSolution, by default it is false //and will send AirPricePoint in the result LowFareSearchRsp lowFareRsp = lfsTest.LowFareShop(solutionResult); if (lowFareRsp != null) { typeBaseAirSegment[] airSegments = lowFareRsp.AirSegmentList; List <typeBaseAirSegment> pricingSegments = new List <typeBaseAirSegment>(); IEnumerator items = lowFareRsp.Items.GetEnumerator(); AirPricingSolution lowestFare = null; AirPricePoint lowest = null; while (items.MoveNext()) { if (solutionResult) { AirPricingSolution airPricingSolution = (AirPricingSolution)items.Current; if (lowestFare == null) { lowestFare = airPricingSolution; } else { if (Helper.ConvertToDecimal(lowestFare.TotalPrice) > Helper.ConvertToDecimal(airPricingSolution.TotalPrice)) { lowestFare = airPricingSolution; } } } else { AirPricePointList airPricePointList = (AirPricePointList)items.Current; if (airPricePointList != null) { foreach (var airPricePoint in airPricePointList.AirPricePoint) { if (lowest == null) { lowest = airPricePoint; } else { if (Helper.ConvertToDecimal(lowest.TotalPrice) > Helper.ConvertToDecimal(airPricePoint.TotalPrice)) { lowest = airPricePoint; } } } } } } if (lowestFare != null) { IEnumerator journeys = lowestFare.Journey.GetEnumerator(); while (journeys.MoveNext()) { Journey journeyDetails = (Journey)journeys.Current; if (journeyDetails != null) { AirSegmentRef[] segmentRef = journeyDetails.AirSegmentRef; string refKey = segmentRef[0].Key; IEnumerator airSegmentList = airSegments.GetEnumerator(); while (airSegmentList.MoveNext()) { typeBaseAirSegment airSeg = (typeBaseAirSegment)airSegmentList.Current; if (airSeg.Key.CompareTo(refKey) == 0) { pricingSegments.Add(airSeg); break; } } } } } if (lowest != null) { IEnumerator pricingInfos = lowest.AirPricingInfo.GetEnumerator(); while (pricingInfos.MoveNext()) { AirPricingInfo priceInfo = (AirPricingInfo)pricingInfos.Current; if (priceInfo != null) { foreach (var flightOption in priceInfo.FlightOptionsList) { FlightOption option = flightOption; IEnumerator options = option.Option.GetEnumerator(); if (options.MoveNext()) { Option opt = (Option)options.Current; if (opt != null) { IEnumerator bookingInfoList = opt.BookingInfo.GetEnumerator(); if (bookingInfoList.MoveNext()) { BookingInfo bookingInfo = (BookingInfo)bookingInfoList.Current; if (bookingInfo != null) { String key = bookingInfo.SegmentRef; IEnumerator airSegmentList = airSegments.GetEnumerator(); while (airSegmentList.MoveNext()) { typeBaseAirSegment airSeg = (typeBaseAirSegment)airSegmentList.Current; if (airSeg.Key.CompareTo(key) == 0) { pricingSegments.Add(airSeg); break; } } } } } } break; } } } } AirPriceRsp priceRsp = AirReq.AirPrice(pricingSegments); AirPricingSolution lowestPrice = null; if (priceRsp != null) { if (priceRsp.AirPriceResult != null) { IEnumerator priceResults = priceRsp.AirPriceResult.GetEnumerator(); if (priceResults.MoveNext())//We would take the first Price Result and will Search for the lowest Price { AirPriceResult result = (AirPriceResult)priceResults.Current; if (result.AirPricingSolution != null) { IEnumerator priceingSolutions = result.AirPricingSolution.GetEnumerator(); while (priceingSolutions.MoveNext()) { AirPricingSolution priceSol = (AirPricingSolution)priceingSolutions.Current; if (lowestPrice == null) { lowestPrice = priceSol; } else { if (Helper.ConvertToDecimal(lowestPrice.TotalPrice) > Helper.ConvertToDecimal(priceSol.TotalPrice)) { lowestPrice = priceSol; } } } } } } if (lowestPrice != null && priceRsp.AirItinerary != null) { AirBookTest book = new AirBookTest(); ConsoleApplication1.UniversalService.AirCreateReservationRsp bookResponse = book.AirBook(lowestPrice, priceRsp.AirItinerary); if (bookResponse != null) { var urLocatorCode = bookResponse.UniversalRecord.LocatorCode; Console.WriteLine("Universal Record Locator Code :" + urLocatorCode); UniversalRetrieveTest univ = new UniversalRetrieveTest(); univ.RetrieveRecord(urLocatorCode); } } } } } catch (Exception e) { //usually only the error message is useful, not the full stack //trace, since the stack trace in is your address space... Console.WriteLine("Error : " + e.Message); } }