public ActionResult LoadTripHistory(int tripId) { ExpenseClient _exp = new ExpenseClient(); var trips = new TripHistory(); trips.tripDetails = _exp.GetTripDetails(tripId).ToList(); return(PartialView("_LoadTripHistory", trips.tripDetails)); }
public ActionResult TripHistory() { ExpenseClient _exp = new ExpenseClient(); var trips = new TripHistory(); trips.tripHistoryList = _exp.GetTripHistory(Convert.ToInt32(Session["UserId"].ToString())).ToList(); trips.tripDetails = _exp.GetTripDetails(0).ToList(); return(View(trips)); }
public static int SaveTripHistory(TripHistory tripHistoryInstance) { if (tripHistoryInstance.Id != 0) { _database.Update(tripHistoryInstance); } else { _database.Insert(tripHistoryInstance); } return(tripHistoryInstance.Id); }
public async Task <bool> AddTripHistory(TripHistory tripHistory) { await _dataContext.TripHistories.AddAsync(tripHistory); try { await _dataContext.SaveChangesAsync(); } catch { return(false); } return(true); }
public async Task AddOrUpdateTripHistory(TripHistory history) { var histories = await GetAllTripHistories().ConfigureAwait(false); var trip = histories.SingleOrDefault(h => h.Vin == history.Vin); if (trip == null) { histories.Add(history); } else { trip.GallonsUsed = history.GallonsUsed; trip.MilesTravelled = history.MilesTravelled; } await SaveHistories(histories).ConfigureAwait(false); }
private async Task <long> Kalman(Route route, VehicleState vehicle, Stop originStop, Stop destinationStop) { //TODO: eventually get alternate predictions here to compare double time = Database.GetTripHistoryCollection().GetCurrentTimeBucket(); TripHistory lastTripHistoryToday = await Database.GetTripHistoryCollection().GetLastTrip(route, originStop, destinationStop); if (lastTripHistoryToday != null) //cannot use if there aren't any vehicles proceeding it today { List <TripHistory> previousHistories = await Database.GetTripHistoryCollection().GetTripHistories(route, originStop, destinationStop, 3, 3); if (previousHistories != null && previousHistories.Count > 0) { //we have enough info, ready to try predictions KalmanPrediction kalman = new KalmanPrediction(); KalmanVehicle kalmanVehicle = new KalmanVehicle(vehicle.BusNumber.ToString()); KalmanVehicleStopDetail kalmanOriginStop = new KalmanVehicleStopDetail(originStop, 0, kalmanVehicle); List <KalmanTripSegment> kalmanSegments = new List <KalmanTripSegment>(); foreach (TripHistory history in previousHistories) { KalmanVehicleStopDetail kalmanEndStop = new KalmanVehicleStopDetail(destinationStop, history.GetTravelTime(), kalmanVehicle); kalmanSegments.Add(new KalmanTripSegment(kalmanOriginStop, kalmanEndStop)); } //time information for earlier KalmanVehicleStopDetail destinationDetailFromEarlier = new KalmanVehicleStopDetail(destinationStop, lastTripHistoryToday.GetTravelTime(), kalmanVehicle); KalmanTripSegment earlierSegment = new KalmanTripSegment(kalmanOriginStop, destinationDetailFromEarlier); double lastError = await Database.GetKalmanErrorCollection().GetKalmanError(originStop.StopID, destinationStop.StopID, route.RouteID); KalmanPredictionResult result = kalman.Predict(earlierSegment, kalmanSegments, lastError); long predictionTime = (long)result.GetResult(); double predictionError = result.GetFilterError(); await Database.GetKalmanErrorCollection().InsertKalmanError(predictionError, originStop.StopID, destinationStop.StopID, route.RouteID); return(predictionTime); } return(-2); } return(-3); }
public CreateInsideViewModel(INavigation navigation, int tripID) { _navigation = navigation; _geoCoder = new Geocoder(); _currentWeather = _weather_sunny; _tripHistory = new TripHistory(); _tripHistory.Id = tripID; _tripHistory.RegisterDate = DateTime.Now; //_imageDatas.Clear(); //_imageDatas.Add(_tripHistory.Image1); //_imageDatas.Add(_tripHistory.Image2); //_imageDatas.Add(_tripHistory.Image3); //_imageDatas.Add(_tripHistory.Image4); //_imageDatas.Add(_tripHistory.Image5); //_imageDatas.Add(_tripHistory.Image6); //_imageDatas.Add(_tripHistory.Image7); //_imageDatas.Add(_tripHistory.Image8); //_imageDatas.Add(_tripHistory.Image9); //_imageDatas.Add(_tripHistory.Image10); //_cameraPictures.Add(Picture1); //_cameraPictures.Add(Picture2); //_cameraPictures.Add(Picture3); //_cameraPictures.Add(Picture4); //_cameraPictures.Add(Picture5); //_cameraPictures.Add(Picture6); //_cameraPictures.Add(Picture7); //_cameraPictures.Add(Picture8); //_cameraPictures.Add(Picture9); //_cameraPictures.Add(Picture10); InsideDate = GetInsideDateFromDateTime(_tripHistory.RegisterDate); OnPropertyChanged(_currentWeather); }
public ActionResult <bool> AddTrip(string location, string date, string feeling) { return(TripHistory.GetInstance().AddTrip(location, date, feeling)); }
public ActionResult <int> GetTripCount() { TripHistory th = TripHistory.GetInstance(); return(th.GetTripCount()); }
public ActionResult <IEnumerable <Trip> > GetTripList() { TripHistory th = TripHistory.GetInstance(); return(th.GetTripList()); }
public async Task AddTripHistory(TripHistory tripHistory) { await _dataContext.TripHistories.AddAsync(tripHistory); await _dataContext.SaveChangesAsync(); }
public async Task InsertTripHistory(TripHistory history) { await Collection.InsertOneAsync(history); }