コード例 #1
0
        private async Task CreateRequirements(ExerciseBody exerciseBody, Exercise newExercise)
        {
            // delete old
            await exerciseRepository.DeleteRequirementsAsync(newExercise.Id);

            // create new
            newExercise.ExerciseRequirements = new List <ExerciseRequirement>();
            foreach (string requirement in exerciseBody.Requirements)
            {
                ExerciseRequirement newRequirement = new ExerciseRequirement
                {
                    Exercise    = newExercise,
                    Requirement = requirement
                };
                newExercise.ExerciseRequirements.Add(newRequirement);
            }
        }