public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            TrackSessionLocation valueAsLocation = value as TrackSessionLocation? ?? TrackSessionLocation.InMemory;

            switch (valueAsLocation)
            {
            case TrackSessionLocation.LocalFile:
                return(AppResources.Text_DataSource_Local);

            case TrackSessionLocation.ServerFile:
                return(AppResources.Text_DataSource_SkyDrive);

            case TrackSessionLocation.ServerWithLocalFile:
                return(AppResources.Text_DataSource_LocalAndOneDrive);

            case TrackSessionLocation.InMemory:
            default:
                return(AppResources.Text_DataSource_InMemory);
            }
        }
 public static TrackSessionViewModel AsViewModel(this TrackSession session, TrackViewModel track, VehicleViewModel vehicle, TimeSpan?bestLapTime, TrackSessionLocation location, string filePath, bool isMetricUnits)
 {
     return(new TrackSessionViewModel
     {
         TrackId = track != null ? track.Id : 0,
         Track = track,
         TrackName = track != null ? track.Name : string.Empty,
         Vehicle = vehicle,
         BestLapTime = session.BestLapTime,
         NumberOfLaps = session.NumberOfLaps,
         DeviceOrientation = session.DeviceOrientation,
         GpsDeviceName = session.GpsDeviceName,
         Location = location,
         LocalFilePath = location == TrackSessionLocation.LocalFile || location == TrackSessionLocation.ServerWithLocalFile ? filePath : string.Empty,
         ServerFilePath = location == TrackSessionLocation.ServerFile ? filePath : string.Empty,
         IsUploaded = location == TrackSessionLocation.ServerFile,
         Laps = new ObservableCollection <LapViewModel>(session.Laps.Select(lap => lap.AsViewModel(bestLapTime, isMetricUnits))),
         Timestamp = session.Timestamp.ToLocalTime(),
         Notes = session.Notes,
         Weather = session.Weather.AsViewModel(isMetricUnits)
     });
 }
 public static TrackSessionHeaderViewModel AsViewModel(this TrackSessionHeader trackSession, string filePath, TrackSessionLocation location, bool isMetricUnits)
 {
     return(new TrackSessionHeaderViewModel
     {
         BestLapTime = trackSession.BestLapTime,
         DeviceOrientation = trackSession.DeviceOrientation,
         GpsDeviceName = trackSession.GpsDeviceName,
         LocalFilePath = location == TrackSessionLocation.LocalFile || location == TrackSessionLocation.ServerWithLocalFile ? filePath : string.Empty,
         ServerFilePath = location == TrackSessionLocation.ServerFile ? filePath : string.Empty,
         IsUploaded = location == TrackSessionLocation.ServerFile,
         Location = location,
         NumberOfLaps = trackSession.NumberOfLaps,
         Timestamp = trackSession.Timestamp.ToLocalTime(),
         TrackId = trackSession.TrackId,
         TrackName = trackSession.TrackName,
         Notes = trackSession.Notes,
         Vehicle = trackSession.Vehicle.AsViewModel(),
         Weather = trackSession.Weather.AsViewModel(isMetricUnits)
     });
 }