//Find a single journey details. public SingleJourney getJourney(Journey theJourney) { SingleJourney result = new SingleJourney(); JourneyModel thisjourney = new JourneyModel(); thisjourney.ECoordLat = theJourney.ECoordLat; thisjourney.ECoordLog = theJourney.ECoordLog; thisjourney.EndTime = theJourney.EndTime; thisjourney.Journeyid = theJourney.JourneyId; thisjourney.NavigateRoute = theJourney.NavigateRoute; thisjourney.SCoordLat = theJourney.SCoordLat; thisjourney.SCoordLog = theJourney.SCoordLog; thisjourney.StartTime = theJourney.StartTime; thisjourney.Status = theJourney.Status; thisjourney.UserProfileId = theJourney.UserProfileId; result.journeyDetails = thisjourney; List <JTracking> theTrack = db.JTracking.Where(s => s.JourneyJourneyId == theJourney.JourneyId).ToList(); foreach (JTracking t in theTrack) { JTrackModel thisTrack = new JTrackModel(); thisTrack.CoordLat = t.CoordLat; thisTrack.CoordLog = t.CoordLog; thisTrack.JourneyJourneyId = t.JourneyJourneyId; thisTrack.Time = t.Time; result.trackDetails.Add(thisTrack); } //result.trackDetails = db.JTracking.Where(s => s.JourneyJourneyId == theJourney.JourneyId).ToList(); return(result); }
public IHttpActionResult retrieveHistory() { Reply reply = new Reply(); String json = ""; List <SingleJourney> journeyList = new List <SingleJourney>(); var userID = User.Identity.GetUserId(); List <Journey> journeys = db.Journey.Where(s => s.UserProfileId == userID).ToList(); if (journeys == null) { return(NotFound()); } foreach (Journey theJourney in journeys) { SingleJourney single = getJourney(theJourney); journeyList.Add(single); } reply.result = "success"; reply.data = JsonConvert.SerializeObject(journeyList); json = JsonConvert.SerializeObject(reply); return(Ok(json)); }