Пример #1
0
        private async Task CreateForms(ExerciseBody exerciseBody, Exercise newExercise)
        {
            // delete old
            await exerciseRepository.DeleteFormsAsync(newExercise.Id);

            // create new
            newExercise.ExerciseForms = new List <ExerciseForm>();
            List <MovementForm> exerciseForms = new List <MovementForm>();

            foreach (MovementForm form in exerciseBody.Forms)
            {
                // if movement form was already added
                if (exerciseForms.Contains(form))
                {
                    continue;
                }
                ExerciseForm newForm = new ExerciseForm
                {
                    Exercise     = newExercise,
                    MovementForm = form
                };
                newExercise.ExerciseForms.Add(newForm);
                exerciseForms.Add(newForm.MovementForm);
            }
        }
Пример #2
0
    private void buttonMatch_Click(object sender, EventArgs e)
    {
        List <Translation> translationForTestList = translationDBservice.getWordsForMatchTest();

        if (translationForTestList.Count() < 4)
        {
            MessageBox.Show("You don't have words in your dictionary to exercise, please add some.");
            return;
        }
        ExerciseForm newForm = new ExerciseForm(wordService, dataContext, translationDBservice, applicationSettingsService);

        newForm.Show();
    }
Пример #3
0
        public async Task <object> Create([FromBody] ExerciseForm exerciseForm)
        {
            Exercise exercise = new Exercise
            {
                Id                 = exerciseForm.Id = exerciseForm.Name.Replace(" ", "-").ToLowerInvariant(),
                Name               = exerciseForm.Name,
                Description        = exerciseForm.Description,
                Difficulty         = exerciseForm.Difficulty,
                ExerciseCategories = exerciseForm.Categories.Select(x => new ExerciseCategory
                {
                    CategoryId = x
                }).ToList()
            };

            _ctx.Add(exercise);
            await _ctx.SaveChangesAsync();

            return(ExerciseViewModels.Default.Compile().Invoke(exercise));
        }