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; }