Beispiel #1
0
        public async Task <Exercise> CreateExercise(ExerciseBody exerciseBody)
        {
            // create exercise
            Exercise newExercise = new Exercise
            {
                Name                 = exerciseBody.Name,
                Media                = exerciseBody.Media,
                ExerciseSteps        = new List <ExerciseStep>(),
                ExerciseRequirements = new List <ExerciseRequirement>(),
                ExerciseForms        = new List <ExerciseForm>()
            };

            // create exercise steps
            await CreateSteps(exerciseBody, newExercise);

            // create exercise requirements
            await CreateRequirements(exerciseBody, newExercise);

            // create exercise forms
            await CreateForms(exerciseBody, newExercise);

            // save exercise to database
            newExercise = await exerciseRepository.CreateAsync(newExercise);

            return(newExercise);
        }