/// <summary>
        /// Retrieves the most recent journey
        /// </summary>
        /// <param name="vehicle">The vehicle to retrieve the most recent journey</param>
        /// <returns>The most recent journey</returns>
        public Journey Recent(Vehicle vehicle)
        {
            Journey recentJourney = null;

            if (List.Count > 0)
            {
                // Group Services by Vehicle ID.
                ObservableCollection <Journey> vehicleJourneys = ByVehicle(vehicle);

                if (vehicleJourneys.Count > 0)
                {
                    recentJourney = vehicleJourneys[0];
                }
            }

            return(recentJourney);
        }
        /// <summary>
        /// Edit a journey using the provided journey and property values
        /// </summary>
        /// <param name="journey">Journey to be referenced and to be modified</param>
        /// <param name="date">Date/time of journey</param>
        /// <param name="distance">Distance of the journey</param>
        public void Edit(Journey journey, DateTime date, int distance)
        {
            var FindJourney = List.FirstOrDefault(j => j.Id == journey.Id);

            if (FindJourney != null)
            {
                FindJourney.Date     = date;
                FindJourney.Distance = distance;

                string statement =
                    $"UPDATE `journeys`" +
                    $"SET " +
                    $"`distance` = {journey.Distance.ToString()}, " +
                    $"`date` = '{journey.Date.ToString("yyyy-MM-dd")}'" +
                    $"WHERE `id` = {journey.Id.ToString()};";

                // Execute statement if able
                ExecuteNonQuery(statement);
            }
        }
        private void LvJourneys_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lvJourneys.SelectedItem is Journey)
            {
                if (online)
                {
                    if (!editMode)
                    {
                        ToggleEditMode(true);
                    }
                }
                else
                {
                    foreach (Control field in fields)
                    {
                        field.IsEnabled = false;
                    }
                }

                selected = ( Journey )lvJourneys.SelectedItem;
                SetSelectedToFields();
            }
        }
        /// <summary>
        /// Add new journey into the collection
        /// </summary>
        /// <param name="vehicle">Vehicle to be referenced on this Journey</param>
        /// <param name="date">Date/time of journey</param>
        /// <param name="distance">Distance of the journey</param>
        public void Add(Vehicle vehicle, DateTime date, int distance)
        {
            int     id      = FindId();
            Journey journey = new Journey(id, vehicle)
            {
                Date     = date,
                Distance = distance,
            };

            List.Add(journey);

            // Prepare SQL query
            string statement =
                $"INSERT INTO `journeys` ( `id`, `vehicle_id`, `distance`, `date`)" +
                $"VALUES (" +
                $"{journey.Id}," +
                $"{journey.VehicleId}," +
                $"{journey.Distance.ToString()}," +
                $"'{journey.Date.ToString("yyyy-MM-dd")}'" +
                $")";

            // Execute statement if able
            ExecuteNonQuery(statement);
        }