private async void saveWorkoutButtonClick(object sender, EventArgs e)
        {
            int workoutID = App.Database.getWorkoutIDFromName(workoutSelected);
            WorkoutPlanWorkout planWorkout         = new WorkoutPlanWorkout(0, cPlan.ID, workoutID);
            string             validatePlanWorkout = planWorkout.validatePlanWorkout(planWorkout);

            if (workoutSelected == "")
            {
                await DisplayAlert("Error Adding Workout to Workout Plan", "Please select a workout to add to workout plan.", "OK");

                return;
            }

            if (validatePlanWorkout == null)
            {
                await App.Database.saveWorkoutPlanWorkout(planWorkout);
            }
            else
            {
                await DisplayAlert("Error Adding Workout to Workout Plan", "Detected the following errors when adding a workout to this plan:" + Environment.NewLine + validatePlanWorkout, "OK");

                return;
            }

            var answer = await DisplayAlert("Workout Added", "Workout added successfuly to plan." + Environment.NewLine + "Would you like to add another workout?", "Yes", "No");

            if (answer)
            {
                selectedWorkout.SelectedItem = null;
            }
            else
            {
                App.Current.MainPage = new MainPage(cTrainer, 1);
            }
        }
Ejemplo n.º 2
0
        public async void deleteWorkoutPlanWorkout(WorkoutPlanWorkoutViewModel viewModel)
        {
            WorkoutPlanWorkout workoutPlanWorkout = new WorkoutPlanWorkout(viewModel.pkID, viewModel.workoutPlanID, viewModel.workoutID);

            await App.Database.DeleteWorkoutPlanWorkout(workoutPlanWorkout);
        }