示例#1
0
        private void MenuMakeExerciseClick(object param)
        {
            MakeExercisePage makeexercisePage = new MakeExercisePage();

            makeexercisePage.DataContext = new MakeExerciseViewModel(CurrentUser);
            Navigator.SubNavigationService.Navigate(makeexercisePage);
        }
示例#2
0
        //If no validating errors, insert exercise in database and reload page
        private void ExerciseCreateClick(object param)
        {
            IsValidating = true;
            string error = string.Empty;

            if ((error = ValidateName()) == null)
            {
                if ((error = ValidateDescription()) == null)
                {
                    if (!Uri.IsWellFormedUriString(URI, UriKind.RelativeOrAbsolute))
                    {
                        URI = null;
                    }
                    List <double> profile = new List <double>()
                    {
                        TextVisual, ImageVisual, Verbal, Auditory, Tactile, Kinesthetic
                    };
                    UpdateProfileValues(profile);
                    ExerciseDescription exDescription = new ExerciseDescription(Description)
                    {
                        AudioPath = this.AudioPath, VideoPath = this.VideoPath, ImagePaths = this.ImagePaths, SolutionPath = this.SolutionPath
                    };
                    Exercise exercise = new Exercise(Name, exDescription, profile, CurrentUser.UserName, DateTime.Now, URI);
                    try
                    {
                        DBConnection.CreateExercise(exercise);

                        MakeExercisePage makeexercisePage = new MakeExercisePage();
                        makeexercisePage.DataContext = new MakeExerciseViewModel(CurrentUser);
                        Navigator.SubNavigationService.Navigate(makeexercisePage);
                    }
                    catch (SqlException)
                    {
                        MessageBox.Show("Kunne ikke oprette forbindelse til databasen!");
                    }
                }
                else
                {
                    MessageBox.Show(error);
                }
            }
            else
            {
                MessageBox.Show(error);
            }
        }