Beispiel #1
0
        //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);
        }
Beispiel #2
0
        //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);
        }
Beispiel #3
0
        //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);
        }
Beispiel #4
0
        //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);
        }
Beispiel #5
0
        //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);
        }
Beispiel #6
0
 //Add new lift
 public Task <int> AddLiftAsync(Lift item)
 {
     if (item.Id != 0)
     {
         return(database.UpdateAsync(item));
     }
     else
     {
         return(database.InsertAsync(item));
     }
 }
Beispiel #7
0
        //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);
                }
            }
        }
Beispiel #8
0
        //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);
            }
        }
Beispiel #9
0
 //Delete lift
 public Task <int> DeleteItemAsync(Lift item)
 {
     return(database.DeleteAsync(item));
 }