public Question FindQuestion(Question question,QuestionGroup questionGroup)
 {
     Question foundQuestion = questionGroup.Questions.SingleOrDefault(q => q.Id == question.Id);
     if (foundQuestion != null)
     {
         return foundQuestion;
     }
     throw new Exception("kunne ikke finde dit spørgsmål i filtret");
 }
 public Question FindQuestion(QuestionGroup questionGroup, int questionId)
 {
     Question foundQuestion = questionGroup.Questions.SingleOrDefault(q => q.Id == questionId);
     if (foundQuestion != null)
     {
         return foundQuestion;
     }
     throw new SearchException("Fejl i FilterLinqSearch:FindQuestion. Kunne ikke finde question i questionGroup id: " + questionGroup.Title + " med id " + questionId);
 }
        public UpdateQuestionGroup(Model.DomainModel.QuestionGroup questionGroup, MainWindow Main)
        {
            InitializeComponent();
            main = Main;
            this.questionGroup = questionGroup;

            QuestionInfoGroupTextBox.Text = questionGroup.Info;
            QuestionGroupTitleTextBox.Text = questionGroup.Title;
            QuestionRankGroupTextBox.Text = questionGroup.Rank.ToString();
        }
 public Question FindQuestion(QuestionGroup questionGroup, int questionId)
 {
     try
     {
         return Search.FindQuestion(questionGroup, questionId);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public AnswerView(MainWindow mainWindow,QuestionGroup questionGroup, Question question)
        {
            InitializeComponent();
            //AnimationClass.fadeOut(viewGrid, 0); AnimationClass.fadeIn(viewGrid, MainWindow.AnimationSpeed);
            this.mainWindow = mainWindow;
            this.questionGroup = questionGroup;
            this.question = question;
 

            TitleLabel.Content = "Svarmulighed til " + question.Title;
            AnswerListBox.ItemsSource = question.Answers.OrderBy(o => o.Rank).ToList();
        }
 public static void QuestionRankAvailable(decimal rank, QuestionGroup questionGroup, int id)
 {
     foreach (Question question in questionGroup.Questions)
         {
             if (question.Rank == rank)
             {
                 if (question.Id != id)
                 {
                     throw new Exception("Rank allerede valgt");
                 }
             }
         }
 }
        public QuestionView(MainWindow mainWindow,QuestionGroup questionGroup)
        {
            try
            {
                InitializeComponent();
                this.mainWindow = mainWindow;
                this.questionGroup = questionGroup;
                TitleLabel.Content = "Spørgsmål til " + questionGroup.Title;
                
                QuestionListBox.ItemsSource = questionGroup.Questions.OrderBy(o => o.Rank).ToList();
            }
            catch (Exception ex)
            {
                mainWindow.ShowError(ex.Message,true);
            }  

            //AnimationClass.fadeOut(viewGrid, 0); AnimationClass.fadeIn(viewGrid, MainWindow.AnimationSpeed);
        }
 public Question FindQuestion(QuestionGroup questionGroup, int questionId)
 {
     return filterSearchController.FindQuestion(questionGroup, questionId);
 }
 public GridPresent(QuestionGroup questionGroup)
 {
     this.QuestionGroup = questionGroup;
    init();   
 }
        public void AddRow(QuestionGroup questionGroup,Grid questionGroupList, string title, decimal rank, bool newRow = false)
        {
            QuestionGroupRows.Add(new QuestionGroupRow(questionGroup,questionGroupList, rowCount, title, rank));
            NewRowCrated();
            rowCount++;

        }
        public QuestionGroupRow(QuestionGroup questionGroup,Grid questionGroupList, int rowCount, string title, decimal rank, bool newRow = false)
        {
            Row = rowCount;
            NewRow = newRow;
            QuestionGroup = questionGroup;

            QuestionGroupUI UI = new QuestionGroupUI();
            questionGroupList.Children.Add(UI.CreateTitleTextBox(rowCount, title));
            questionGroupList.Children.Add(UI.CreateRankTextBox(rowCount, rank.ToString()));
            questionGroupList.Children.Add(UI.CreateInfoButton(rowCount, "Info"));
            questionGroupList.Children.Add(UI.CreateDeleteButton(rowCount, "Slet"));
            questionGroupList.Children.Add(UI.CreateSaveButton(rowCount, "Gem"));
            questionGroupList.Children.Add(UI.CreateOpenButton(rowCount, "Åben"));
        }
        // Window Event
        private void createNewQuestionGroup(string title, decimal rank, string info)
        {
            QuestionGroup questionGroup = new QuestionGroup()
            {
                Info = info,
                Title = title,
                Rank = rank
            };
            QuestionGroup questionGroupNotTranslated = new QuestionGroup()
            {
                Id = questionGroup.Id,
                Info = info,
                Title = title   + " (not translated)",
                Rank = rank
            };
            mainWindow.ModelFacade.Filter.QuestionGroups.Add(questionGroup);
            saveAndRefresh();

            var LoadedFilterType = mainWindow.ModelFacade.Filter.Type;

            if (LoadedFilterType != FilterType.TestTemplate)
            {
                if (LoadedFilterType != FilterType.DanishTemplate)
                {
                    var mf = new ModelFacade(FilterType.DanishTemplate);
                    mf.Filter.QuestionGroups.Add(questionGroupNotTranslated);
                    mf.Save();
                }
                if (LoadedFilterType != FilterType.EnglishTemplate)
                {
                    var mf = new ModelFacade(FilterType.EnglishTemplate);
                    mf.Filter.QuestionGroups.Add(questionGroupNotTranslated);
                    mf.Save();
                }
                if (LoadedFilterType != FilterType.DeutschTemplate)
                {
                    var mf = new ModelFacade(FilterType.DeutschTemplate);
                    mf.Filter.QuestionGroups.Add(questionGroupNotTranslated);
                    mf.Save();
                }
            }

        }