Exemplo n.º 1
0
        public TrackDetailViewModel(IRepoManager repoManager, INavigation navigation, IMotiveConfiguration motiveConfig, TrackEntry trackEntry)
        {
            _repoManager  = repoManager ?? throw new ArgumentNullException(nameof(repoManager));
            _navigation   = navigation ?? throw new ArgumentNullException(nameof(navigation));
            _trackEntry   = trackEntry ?? throw new ArgumentNullException(nameof(trackEntry));
            _motiveConfig = motiveConfig ?? throw new ArgumentNullException(nameof(Motive));

            TransportationModeEntry modeEntry = _repoManager.TransportationModeRepository.GetLastWithTrackEntry(_trackEntry.Id);

            TransportModeSelectionCommand = new Command(async() =>
            {
                await _navigation.PushModalAsync(new NavigationPage(new TransportSelectionPage(_trackEntry)));
            });

            OpenTrackMotiveCommand = new Command(async() =>
            {
                TrackDetailMotivePage motivePage = new TrackDetailMotivePage(Motive);
                await _navigation.PushModalAsync(new NavigationPage(motivePage));
            });

            DataItems = new ObservableRangeCollection <ListItem>();

            if (_motiveConfig.Tracks)
            {
                PrepareForMotive();
            }

            CompletedTransport = modeEntry != null;
        }
Exemplo n.º 2
0
        public void FinishedTransportSelection()
        {
            //convert to transportationmodeentry objects
            var selectedTransportModes = GetSelectedTransportModes();

            var Timestamp = DateTimeOffset.Now;

            TransportationModeEntry selectedTransportationModeEntry = new TransportationModeEntry
            {
                Timestamp = Timestamp,
                TrackId   = _trackEntry.Id
            };

            StringBuilder stringBuilder = new StringBuilder();


            foreach (var sel in selectedTransportModes)
            {
                if (stringBuilder.Length != 0)
                {
                    stringBuilder.Append(",");
                }
                stringBuilder.Append(sel);
            }

            selectedTransportationModeEntry.ActiveModes = stringBuilder.ToString();

            _repoManager.TransportationModeRepository.Add(selectedTransportationModeEntry);
        }
Exemplo n.º 3
0
        private void SetActualTransportModes()
        {
            List <TransportModeItem> transports = TransportModeItem.GetPossibleTransportModes(_transportConfig);
            TransportationModeEntry  trackEntry = _repoManager.TransportationModeRepository.GetLastWithTrackEntry(_trackEntry.Id);

            IList <string> activeModes = new List <string>();

            if (trackEntry?.ActiveModes != null)
            {
                activeModes = trackEntry.ActiveModes.Split(',').ToList();
            }

            // Add the default transport modes, while removing them from (ref) activeModes
            foreach (TransportModeItem mi in transports)
            {
                items.Add(mi, CheckModeIsInTransportEntry(mi.Id, ref activeModes));
            }

            // Add any remaining activemodes
            foreach (string aMode in activeModes)
            {
                items.Add(new TransportModeItem()
                {
                    Id = aMode, Name = aMode
                }, true);
            }
        }
Exemplo n.º 4
0
 public static TabiApiClient.Models.TransportationMode ToApiModel(this TransportationModeEntry entry)
 {
     return(new TabiApiClient.Models.TransportationMode()
     {
         LocalTrackId = entry.TrackId,
         DeviceId = Settings.Current.Device,
         Timestamp = entry.Timestamp,
         ActiveModes = entry.ActiveModes.Split(','),
     });
 }