private async Task EndRun()
 {
     if (await DisplayAlert("Finish Run?", "Are you sure you want to end your run?", "Yes", "No"))
     {
         if (_hasStoppedService == false) // should always be true here I think.
         {
             StopLocationService();
             _timer.Stop();
             var duration = DateTime.UtcNow - (_startTime + _pauseOffset);
             var runData  = new RunData()
             {
                 Start    = _startTime,
                 End      = DateTime.UtcNow,
                 Distance = _totalDistance,
                 Elapsed  = duration,
                 Segments = /*TrainingDay != null ? RunSegments :*/ new List <RunSegment>()
                 {
                     new RunSegment()
                     {
                         Distance  = _totalDistance,
                         Duration  = duration,
                         Locations = _locations,
                         Speed     = SegmentSpeeds.None,
                         StartDate = _startTime,
                         Type      = SegmentTypes.Time,
                         ValueType = SegmentValueTypes.Minutes
                     }
                 }
             };
             var runStorage = new RunDataStorageHelper();
             var response   = runStorage.Insert(runData);
             await Navigation.PopAsync();
         }
     }
 }
Ejemplo n.º 2
0
        public LogsPage()
        {
            InitializeComponent();
            var runData = new RunDataStorageHelper().GetAll();

            try
            {
                var logs = runData.GroupBy(r => r.TrainingProgramId).Select(g => new LogGroup(GetPlanTitle(g.Key), g.OrderByDescending(r => r.Start)));
                Logs = logs;
            }
            catch (Exception ex)
            {
                var thing = ex.Message;
            }
            LogListView.ItemsSource   = Logs;
            LogListView.ItemSelected += LogListView_ItemSelected;
        }