Пример #1
0
        private async void EndBtn_ClickedAsync(object sender, EventArgs e)
        {
            IsRunning = false;

            StartBtn.IsVisible  = true;
            PauseBtn.IsVisible  = false;
            ResumeBtn.IsVisible = false;
            EndBtn.IsEnabled    = false;

            bool answer = await DisplayAlert("Great Run!", "Would you like to save it to history?", "Yes", "No");

            if (answer)
            {
                CalculationClass calculationsClass = new CalculationClass();
                FinalSpeed = calculationsClass.finalSpeed(FinalSpeed, hr, min, sec);
                try
                {
                    var db = App.database;

                    var tableItems = new ExerciseTable
                    {
                        DURATION = TimerLabel.Text,
                        DISTANCE = TimerDistance.Text,
                        AVGSPEED = FinalSpeed.ToString(),
                        DATETIME = DateTime.Now
                    };

                    await db.SaveItemAsync(tableItems);
                }
                catch (SQLiteException ex)
                {
                    TimerLabel.Text = ex.ToString();
                }
            }
        }
Пример #2
0
 public Task <int> SaveItemAsync(ExerciseTable item)
 {
     if (item.ID != 0)
     {
         return(database.UpdateAsync(item));
     }
     else
     {
         return(database.InsertAsync(item));
     }
 }
Пример #3
0
 public Task <int> DeleteItemAsync(ExerciseTable item)
 {
     return(database.DeleteAsync(item));
 }