public JourneyDetail GetStaringPointForJourney() { JourneyDetail journeyDetail = new JourneyDetail(); if (ApplicationClass.currentRunningJourneyId != 0) { using (var db = new SQLiteConnection(dbPath)) { try { var currentJourney = db.Table <JourneyDetail>().Where(o => o.JourneyId == ApplicationClass.currentRunningJourneyId).FirstOrDefault(); if (currentJourney != null) { journeyDetail.JourneyId = currentJourney.JourneyId; journeyDetail.Longitude = currentJourney.Longitude; journeyDetail.Latitude = currentJourney.Latitude; journeyDetail.CaptureTime = currentJourney.CaptureTime; } } catch (Exception ex) { throw ex; //exception handling code to go here } } } return(journeyDetail); }
public void AddLocationToRunningJourney(string longitude, string latitude) { if (ApplicationClass.currentRunningJourneyId != 0) { using (var db = new SQLiteConnection(dbPath)) { try { JourneyDetail journeyDetail = new JourneyDetail(); journeyDetail.JourneyId = ApplicationClass.currentRunningJourneyId; journeyDetail.Longitude = longitude; journeyDetail.Latitude = latitude; journeyDetail.CaptureTime = DateTime.Now; db.Insert(journeyDetail); } catch (Exception ex) { throw ex; //exception handling code to go here } } } }
public FlightSearchResult PerformSearch(FlightSearch flightSearch, int searchId) { FlightSearchResult flightSearchResult = new FlightSearchResult(); AirServiceSoapClient airServiceSoapClient = new AirServiceSoapClient(); var authenticateResponse = gatewayService.GetToken(); if (!authenticateResponse.Success) { flightSearchResult.Success = false; flightSearchResult.ErrorMessage = "Could not get token"; return(flightSearchResult); } // now lets try a search var JourneyDetails = new JourneyDetail[] { new JourneyDetail { DepartureDateTime = DateTime.Now.Date.AddDays(30).AddHours(9), DeparturePoint = "LON", DeparturePointIsCity = true, DestinationPoint = "DXB", DestinationPointIsCity = false }, new JourneyDetail { DepartureDateTime = DateTime.Now.Date.AddDays(37).AddHours(9), DeparturePoint = "DXB", DeparturePointIsCity = false, DestinationPoint = "LON", DestinationPointIsCity = true } }; var airSearchResult = airServiceSoapClient.Search(new AirService.AuthHeader { Token = authenticateResponse.Token.Value }, new AirSearch { CabinClass = CabinClasses.All, FareType = FareTypes.All, FlexiDays = 0, SelectedAirlines = null, SessionID = "FlightSearch" + searchId, MultipleCabinClasses = new CabinClasses[] { CabinClasses.All }, // change this if we want business etc... AdultPaxCount = 2, ChildPaxCount = 0, ChildAges = null, InfantPaxCount = 0, JourneyDetails = JourneyDetails, SearchType = SearchTypes.Availability, SortOrder = SortOrders.Price, DirectFlightsOnly = false }); // check if we have results // process them into our object // apply markup to the flights flightSearchResult.Success = true; flightSearchResult.ErrorMessage = "There was " + airSearchResult.Results.Result.Length + " results starting at £" + airSearchResult.Results.Result[0].AdultTotal; return(flightSearchResult); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); ActionBar actionBar = ((Activity)this).ActionBar; actionBar.SetDisplayShowHomeEnabled(true); actionBar.SetLogo(Resource.Drawable.ic_launcher); actionBar.SetDisplayUseLogoEnabled(true); SetContentView(Resource.Layout.JourneySummary); // Create your application here if (ApplicationClass.currentRunningJourneyId != 0) { try { this.progressLayout = FindViewById <ProgressBar>(Resource.Id.progressLayout); geoCoder = new Geocoder(this); this.progressLayout.Visibility = ViewStates.Gone; var lblStartDate = FindViewById <TextView>(Resource.Id.lblStartDate); var lblFrom = FindViewById <TextView>(Resource.Id.lblFrom); var lblTo = FindViewById <TextView>(Resource.Id.lblTo); var lblDuration = FindViewById <TextView>(Resource.Id.lblDuration); var lblCost = FindViewById <TextView>(Resource.Id.lblCost); DataManager dataManager = new DataManager(); Journey lastJourney = dataManager.GetLastJourney(); if (lastJourney.JourneyId != 0) { JourneyDetail journeyDetailStart = dataManager.GetStaringPointForJourney(); JourneyDetail journeyDetailEnd = dataManager.GetEndPointForJourney(); if (journeyDetailStart.JourneyId != 0 && journeyDetailEnd.JourneyId != 0) { if (lblStartDate != null) { lblStartDate.Text = "Start at : " + lastJourney.StartDate.ToString("dd/MM/yyyy hh:mm"); //string fromLocation = ""; //string toLocation = ""; GetLocationNameAsync(Convert.ToDouble(journeyDetailStart.Latitude), Convert.ToDouble(journeyDetailStart.Longitude), lblFrom, "From : "); //lblFrom.Text = "From: " + fromLocation; GetLocationNameAsync(Convert.ToDouble(journeyDetailEnd.Latitude), Convert.ToDouble(journeyDetailEnd.Longitude), lblTo, "To : "); //lblTo.Text = "To: " + toLocation,"From : " lblDuration.Text = "Duration: " + (lastJourney.EndDate - lastJourney.StartDate).Minutes.ToString(); lblCost.Text = "Cost: £" + CalculateCost((lastJourney.EndDate - lastJourney.StartDate).Minutes).ToString(); } else { ShowMessage("No view found to load"); } } else { ShowMessage("GPS Coordinates not captured for this journey"); } } else { ShowMessage("Journey details not found"); } } catch (Exception ex) { ShowMessage(ex.Message.ToString()); } } }
public FlightSearchResult PerformSearch(FlightSearch flightSearch, int searchId) { FlightSearchResult flightSearchResult = new FlightSearchResult(); AirServiceSoapClient airServiceSoapClient = new AirServiceSoapClient(); var authenticateResponse = gatewayService.GetToken(); if (!authenticateResponse.Success) { flightSearchResult.Success = false; flightSearchResult.ErrorMessage = "Could not get token"; return flightSearchResult; } // now lets try a search var JourneyDetails = new JourneyDetail[] { new JourneyDetail { DepartureDateTime = DateTime.Now.Date.AddDays(30).AddHours(9), DeparturePoint = "LON", DeparturePointIsCity = true, DestinationPoint = "DXB", DestinationPointIsCity = false }, new JourneyDetail { DepartureDateTime = DateTime.Now.Date.AddDays(37).AddHours(9), DeparturePoint = "DXB", DeparturePointIsCity = false, DestinationPoint = "LON", DestinationPointIsCity = true } }; var airSearchResult = airServiceSoapClient.Search(new AirService.AuthHeader { Token = authenticateResponse.Token.Value }, new AirSearch { CabinClass = CabinClasses.All, FareType = FareTypes.All, FlexiDays = 0, SelectedAirlines = null, SessionID = "FlightSearch" + searchId, MultipleCabinClasses = new CabinClasses[] { CabinClasses.All }, // change this if we want business etc... AdultPaxCount = 2, ChildPaxCount = 0, ChildAges = null, InfantPaxCount = 0, JourneyDetails = JourneyDetails, SearchType = SearchTypes.Availability, SortOrder = SortOrders.Price, DirectFlightsOnly = false }); // check if we have results // process them into our object // apply markup to the flights flightSearchResult.Success = true; flightSearchResult.ErrorMessage = "There was " + airSearchResult.Results.Result.Length + " results starting at £" + airSearchResult.Results.Result[0].AdultTotal; return flightSearchResult; }