private bool IsNameAlreadyExists() { bool isExists = false; if (this.gridEditCategory.IsVisible == true) { isExists = GridLineCategory.IsNameAlreadyExists(this.textBoxCategoryName.Text); } else if (this.gridEditTest.IsVisible == true) { isExists = GridLineTest.IsNameAlreadyExists( this.textBoxTestName.Text, this.entityParentId); } else if (this.gridEditQuestion.IsVisible == true) { isExists = GridLineQuestion.IsNameAlreadyExists( this.textBoxQuestionName.Text, this.entityParentId); } else if (this.gridEditAnswer.IsVisible == true) { isExists = GridLineAnswer.IsNameAlreadyExists( this.textBoxAnswerText.Text, this.entityParentId); } return(isExists); }
/// <summary> /// Показать ответы выбранного вопроса. /// </summary> /// <param name="idQuestion">Id выбранного вопроса.</param> private void ShowAnswersForSelectedOfQuestion(int idQuestion) { this.ShowHeaderAnswer(); this.ClearTheList(); using (TestingSystemEntities db = new TestingSystemEntities()) { this.level = Level.AnswersForSelectedOfQuestion; var listOfAnswersCurrentQuestion = ( from answer in db.Answer where answer.QuestionId == idQuestion select answer ) .ToList(); GridLineAnswer gridLineAnswer = null; for (int i = 0; i < listOfAnswersCurrentQuestion.Count(); i++) { gridLineAnswer = new GridLineAnswer( i, listOfAnswersCurrentQuestion[i] ); // Установить стиль кнопки внутри grid (gridLineAnswer.Children[0] as Button).Style = (Style)(this.Resources["styleButtonForList"]); this.CreateEditingButtons(gridLineAnswer, listOfAnswersCurrentQuestion[i].Id); this.stackPanelSelection.Children.Add(gridLineAnswer); } if (gridLineAnswer == null) { gridLineAnswer = new GridLineAnswer(); gridLineAnswer.QuestionId = this.currentIdQuestion; } if (this.isTeacher) { this.CreateAddButton(gridLineAnswer); } } }