private void AddExistingQuestion()
        {
            if (SelectedExistingQuestion == null)
            {
                return;
            }
            if (TemplateQuestions.Any(t => t.Question.Equals(SelectedExistingQuestion)))
            {
                return;
            }

            var max = TemplateQuestions.Max(t => t.Order);
            var checklistQuestion = new ChecklistQuestion
            {
                Checklist = Checklist,
                Order     = max == null ? 0 : max + 1,
                Question  = SelectedExistingQuestion
            };

            TemplateQuestions.Add(checklistQuestion);
            SelectedTemplateQuestion = checklistQuestion;
        }
        private void AddNewQuestion()
        {
            if (SelectedQuestionType == null)
            {
                return;
            }

            var newQuestion = new Database.Question
            {
                QuestionType = SelectedQuestionType,
                Hash         = MD5.Crypt($"{SelectedQuestionType.Name}-{DateTime.Now}")
            };
            var max = TemplateQuestions.Max(t => t.Order);
            var checklistQuestion = new ChecklistQuestion
            {
                Checklist = Checklist,
                Order     = max == null ? 0 : max + 1,
                Question  = newQuestion
            };

            TemplateQuestions.Add(checklistQuestion);
            SelectedTemplateQuestion = checklistQuestion;
        }
        public override void OnEnter()
        {
            if (Settings.IsOfflineMode)
            {
                MessageBox.Show("Dit scherm is niet beschikbaar in offline mode.");
                _router.GoBack();
                return;
            }

            TemplateQuestions.Clear();

            if (ViewBag?.Template == null)
            {
                Checklist = new Checklist();
                return;
            }

            Checklist = ViewBag.Template.GetCleanModel();

            const string regex = "\\s{1}[Vv]{1}\\d{1,}$";

            if (Regex.Match(Checklist.Name, regex).Success)
            {
                Checklist.Name = Regex.Replace(Checklist.Name, regex, string.Empty);
            }

            Checklist.Name += $" v{Checklist.Version}";

            RaisePropertyChanged(nameof(Checklist));

            _checklistQuestionRepository.GetChecklistQuestions(Checklist.Parent).ForEach(q => TemplateQuestions.Add(q.GetCleanModel()));

            _questionRepository.All().ForEach(ExistingQuestions.Add);
        }