Inheritance: BaseDataObject
        public async Task<bool> ExecuteDeleteTripCommand(Trip trip)
        {
            if (IsBusy)
                return false;

            Logger.Instance.Track("DeleteTrip");
            var progress = UserDialogs.Instance.Loading("Deleting Trip...", show: false, maskType: MaskType.Clear);

            try
            {
                var result =
                    await
                        UserDialogs.Instance.ConfirmAsync($"Are you sure you want to delete trip: {trip.Name}?",
                            "Delete trip?", "Delete", "Cancel");

                if (!result)
                    return false;

                progress?.Show();

                await StoreManager.TripStore.RemoveAsync(trip);

                Trips.Remove(trip);
            }
            catch (Exception ex)
            {
                Logger.Instance.Report(ex);
            }
            finally
            {
                progress?.Dispose();
            }

            return true;
        }
 public CurrentTripViewModel()
 {
     CurrentTrip = new Trip
     {
         UserId = Settings.Current.UserUID,
         Points = new ObservableRangeCollection<TripPoint>()
     };
     photos = new List<Photo>();
     fuelConsumptionRate = 0;
     FuelConsumptionUnits = Settings.MetricUnits ? "Liters" : "Gallons";
     DistanceUnits = Settings.MetricDistance ? "Kilometers" : "Miles";
     ElapsedTime = "0s";
     Distance = "0.0";
     FuelConsumption = "N/A";
     EngineLoad = "N/A";
     obdDataProcessor = OBDDataProcessor.GetProcessor();
 }
 public PastTripsDetailViewModel(Trip trip) : this()
 {
     Title = trip.Name;
     Trip = trip;
 }
        public async Task<bool> SaveRecordingTripAsync(string name = "")
        {
            if (IsRecording)
                return false;

            if (CurrentTrip.Points?.Count < 1)
            {
                Logger.Instance.Track("Attempt to save a trip with no points!");
                return false;
            }
            IsBusy = true;
            var tripId = CurrentTrip.Id;

            try
            {
                if (string.IsNullOrWhiteSpace(name))
                {
                    CurrentTrip.Name = DateTime.Now.ToString("d") + " " + DateTime.Now.ToString("t");
                    var result = await Acr.UserDialogs.UserDialogs.Instance.PromptAsync(new Acr.UserDialogs.PromptConfig
                    {
                        Text = CurrentTrip.Name,
                        OkText = "OK",
                        IsCancellable = false,
                        Title = "Name of Trip",
                        Message = String.Empty,
                        Placeholder = String.Empty
                    });
                    CurrentTrip.Name = result?.Text ?? string.Empty;
                }
                else
                {
                    CurrentTrip.Name = name;
                }

                ProgressDialogManager.LoadProgressDialog("Saving trip...");

                if (Logger.BingMapsAPIKey != "____BingMapsAPIKey____")
                {

                    CurrentTrip.MainPhotoUrl =
                        $"http://dev.virtualearth.net/REST/V1/Imagery/Map/Road/{CurrentPosition.Latitude.ToString(CultureInfo.InvariantCulture)},{CurrentPosition.Longitude.ToString(CultureInfo.InvariantCulture)}/15?mapSize=500,220&key={Logger.BingMapsAPIKey}";
                }
                else
                {
                    CurrentTrip.MainPhotoUrl = string.Empty;
                }
                CurrentTrip.Rating = 90;

                await StoreManager.TripStore.InsertAsync(CurrentTrip);

                foreach (var photo in photos)
                {
                    photo.TripId = CurrentTrip.Id;
                    await StoreManager.PhotoStore.InsertAsync(photo);
                }

                CurrentTrip = new Trip { Points = new ObservableRangeCollection<TripPoint>() };

                ElapsedTime = "0s";
                Distance = "0.0";
                FuelConsumption = "N/A";
                EngineLoad = "N/A";

                OnPropertyChanged(nameof(CurrentTrip));
                OnPropertyChanged("Stats");
                NeedSave = false;
                Logger.Instance.Track("SaveRecording");
                return true;
            }
            catch (Exception ex)
            {
                Logger.Instance.Report(ex);
            }
            finally
            {
                
                IsBusy = false;

                ProgressDialogManager.DisposeProgressDialog();
            }
            Logger.Instance.Track("SaveRecording failed for trip " + tripId);
            return false;
        }