//Add one to reps public int AddRep(Lift lift) { int newReps = lift.Reps + 1; database.QueryAsync <Lift>("UPDATE LIFTS SET REPS =" + newReps.ToString() + " WHERE ID = " + lift.Id); return(newReps); }
//Add weight long press public int AddWeightLongPress(Lift lift) { int newWeight = lift.Weight + 10; database.QueryAsync <Lift>("UPDATE LIFTS SET WEIGHT =" + newWeight.ToString() + " WHERE ID = " + lift.Id); return(newWeight); }
//Subtract reps button private async void btnMinusReps_Clicked(object sender, EventArgs e) { var b = (Button)sender; Lift lift = (Lift)b.CommandParameter; dataAccess.SubRep(lift); Exercises.ItemsSource = await dataAccess.GetFilteredLifts(exerciseName); }
//Subtract one from reps public int SubRep(Lift lift) { int newReps = lift.Reps - 1; if (newReps < 0) { newReps = 0; } database.QueryAsync <Lift>("UPDATE LIFTS SET REPS =" + newReps.ToString() + " WHERE ID = " + lift.Id); return(newReps); }
//Subtract weight public int SubWeight(Lift lift) { int newWeight = lift.Weight - 5; if (newWeight < 0) { newWeight = 0; } database.QueryAsync <Lift>("UPDATE LIFTS SET WEIGHT =" + newWeight.ToString() + " WHERE ID = " + lift.Id); return(newWeight); }
//Add new lift public Task <int> AddLiftAsync(Lift item) { if (item.Id != 0) { return(database.UpdateAsync(item)); } else { return(database.InsertAsync(item)); } }
//Delete Lift button private async void btnDeleteLift_Clicked(object sender, EventArgs e) { var b = (Button)sender; Lift lift = (Lift)Exercises.SelectedItem; if (lift != null) { string action = await DisplayActionSheet("Exercise will be permanently deleted", "Cancel", "Delete"); Debug.WriteLine("Action: " + action); if (action.Equals("Delete")) { await dataAccess.DeleteItemAsync(lift); Exercises.ItemsSource = await dataAccess.GetFilteredLifts(exerciseName); } } }
//Add Lift button private async void btnAddLift_Clicked(object sender, EventArgs e) { var b = (Button)sender; if (entryAddExercise.Text == null) { return; } else { Lift lift = new Lift { ExerciseName = entryAddExercise.Text, Muscle = exerciseName, Reps = 0, Weight = 0 }; entryAddExercise.Text = ""; await dataAccess.AddLiftAsync(lift); Exercises.ItemsSource = await dataAccess.GetFilteredLifts(exerciseName); } }
//Delete lift public Task <int> DeleteItemAsync(Lift item) { return(database.DeleteAsync(item)); }