예제 #1
0
        private async void Save_Clicked(object sender, EventArgs e)
        {
            //If entries are valid
            if (MasterModel.vd.FormEntriesValid(FormController.GetAllEntries(gridForm)) == true)
            {
                try
                {
                    //Save
                    SelectedType.Reps     = RepController.SaveRepsFromEntries(gridForm, repeatableLblText);
                    Exercise.Types[Index] = SelectedType;
                    await MasterModel.DAL.SaveSelectedExerciseAsync(Exercise);

                    await Navigation.PopAsync();
                }
                catch (Exception ex)
                {
                    //Display error
                    await DisplayAlert("Error", ex.Message, "OK");

                    throw;
                }
            }
            //Entries are invalid
            else
            {
                //Display error
                await DisplayAlert("Error", MasterModel.vd.error, "OK");
            }
        }
예제 #2
0
 private async void NewType_Clicked(object sender, EventArgs e)
 {
     if (MasterModel.vd.FormEntriesValid(new string[] { entryRep.Text }) == true)
     {
         List <Rep> tempReps = RepController.SaveRepsFromEntries(gridForm, repeatableLblText);
         Exercise.Types.Add(new ExerciseType
         {
             Name = entryType.Text,
             Reps = tempReps
         });
         ResetForm();
         entryType.Focus();
     }
     else
     {
         await DisplayAlert("Error", MasterModel.vd.error, "OK");
     }
 }
예제 #3
0
        private async void Save_Clicked(object sender, EventArgs e)
        {
            //Ugly band-aid fix for if types already exist but the user just
            //wants to save...
            if (MasterModel.vd.FormEntriesValid(new string[] { entryName.Text }) == true)
            {
                //If there are more than one exercise types
                if (Exercise.Types.Count > 0)
                {
                    //If there are entries on the current page then add those too.
                    if (MasterModel.vd.FormEntriesValid(FormController.GetAllEntries(gridForm)) == true)
                    {
                        Exercise.Types.Add(new ExerciseType {
                            Name = entryType.Text, Reps = RepController.SaveRepsFromEntries(gridForm, repeatableLblText)
                        });
                    }
                    //In the case the if statement isn't met
                    //it ignores the current form and saves the data
                    await SaveData();

                    return;
                }
            }

            if (MasterModel.vd.FormEntriesValid(FormController.GetAllEntries(gridForm)) == false)
            {
                await DisplayAlert("Error", MasterModel.vd.error, "OK");

                return;
            }

            //At this point, the form is valid and is the very first exercise type.
            Exercise.Types.Add(new ExerciseType {
                Name = entryType.Text, Reps = RepController.SaveRepsFromEntries(gridForm, repeatableLblText)
            });
            await SaveData();
        }