public IHttpActionResult GetDestinationName(string id) { XmlManager.TripAndWeatherSheet tripAndWeatherSheet = new XmlManager.TripAndWeatherSheet(); try { XmlManager.LocationSheetList locationSheetList; locationSheetList = ResRobot.ResRobot.GetLocations(id); XmlManager.TripSheet tripSheet = new XmlManager.TripSheet(); tripSheet = ResRobot.ResRobot.GetTripBetweenLocations(740000133, int.Parse(locationSheetList.LocationSheets.First().ID)); XmlManager.WeatherSheet weatherSheet = SMHI.SMHI.GetWeatherFromSMHIByLonLatDateTime(tripSheet.DestinationLon, tripSheet.DestinationLat, DateTime.Parse(tripSheet.DestinationTime)); tripAndWeatherSheet.tripSheet = tripSheet; tripAndWeatherSheet.weatherSheet = weatherSheet; } catch (Exception ex) { tripAndWeatherSheet.Error = true; tripAndWeatherSheet.ExMsg = ex.Message; } return(Ok(tripAndWeatherSheet)); }
/// <summary> /// GETs a trip from Örebro Centrailstation to destination ID. ID must correspond with the ID for a location from resrobot API. /// </summary> /// <param name="id">A resrobot ID for a location.</param> /// <param name="connectionString">WebService API URL.</param> /// <returns>Returns information about a trip from Örebro Centralstation.</returns> public static XmlManager.TripSheet ReceiveTripToDestination(int id, string connectionString) { string data = new WebClient().DownloadString(connectionString + "/api/trip/" + id); XmlManager.TripSheet xmlSheet = JsonConvert.DeserializeObject <XmlManager.TripSheet>(data); return(xmlSheet); }
public IHttpActionResult GetTripToDestination(int id) { XmlManager.TripSheet tripSheet = new XmlManager.TripSheet(); try { //Always travel from Örebro Centrailstation, ResRobot ID: 740000133 tripSheet = ResRobot.ResRobot.GetTripBetweenLocations(740000133, id); } catch (Exception ex) { tripSheet.Error = true; tripSheet.ExMsg = ex.Message; } return(Ok(tripSheet)); }
/// <summary> /// Returns a TripSheet with information about a trip between two locations. /// </summary> /// <param name="id1">ID of location 1</param> /// <param name="id2">ID of location 2</param> /// <returns></returns> public static XmlManager.TripSheet GetTripBetweenLocations(int id1, int id2) { XmlReader Reader = XmlReader.Create ("https://api.resrobot.se/v2/trip?key=0e8eb279-dd0e-4b30-8f5d-ca0e244f9b6b&originId=" + id1 + "&destId=" + id2 + "&format=xml"); XmlSerializer seri = new XmlSerializer(typeof(XmlTripsClass.TripList)); XmlTripsClass.TripList tripList = (XmlTripsClass.TripList)seri.Deserialize(Reader); XmlManager.TripSheet tripSheet = new XmlManager.TripSheet(); tripSheet = XmlManager.XmlManager.MakeTripSheet(tripList.Trip.First().LegList.Leg.First().Origin.Name, tripList.Trip.First().LegList.Leg.First().Origin.Time, tripList.Trip.First().LegList.Leg.First().Origin.Date, tripList.Trip.First().LegList.Leg.First().Origin.Lon, tripList.Trip.First().LegList.Leg.First().Origin.Lat, tripList.Trip.First().LegList.Leg.Last().Destination.Name, tripList.Trip.First().LegList.Leg.Last().Destination.Time, tripList.Trip.First().LegList.Leg.Last().Destination.Date, tripList.Trip.First().LegList.Leg.Last().Destination.Lon, tripList.Trip.First().LegList.Leg.Last().Destination.Lat); return(tripSheet); }