public bool UpdateQuestion(QueDTOQuestionstion question) { string message = "UpdateQuestion:"; SendMessage(message); // надсилаємо повідомлення на серверну частину для отримання Thread.Sleep(700); SendObject(question); // надсилаємо список id тестів групи Thread.Sleep(700); var obj = RecieveObject(); // приймаємо відповідь з сервера bool result = false; if (obj is bool) // перевіряємо чи це список тестів { result = (bool)obj; // приводимо до потрібного типу } return(result); }
public int SaveQuestion(QueDTOQuestionstion question) { string message = "SaveQuestion:"; SendMessage(message); // надсилаємо повідомлення на серверну частину для отримання Thread.Sleep(1010); SendObject(question); // надсилаємо список id тестів групи Thread.Sleep(1010); var obj = RecieveObject(); // приймаємо відповідь з сервера int newId = 0; if (obj is int) // перевіряємо чи це список тестів { return((int)obj); // приводимо до потрібного типу } return(newId); }
private void CreateTestButton_Click(object sender, RoutedEventArgs e) { if (questionTypeId != -1) { if (QuestionText.Text != "" && AnswerOptions.Text != "" && CorrectAnswer.Text != "" && QuestionCountScores.Text != "") { double num2; bool isDoubleNum = double.TryParse(QuestionCountScores.Text, out num2); if (isDoubleNum == true && double.Parse(QuestionCountScores.Text) > 0) { QueDTOQuestionstion dTOQuestionstion = new QueDTOQuestionstion() { QuestionText = QuestionText.Text, AnswerOption = AnswerOptions.Text, QuestionAnswer = CorrectAnswer.Text, QuestionCountScores = double.Parse(QuestionCountScores.Text), QuestionTypeId = questionTypeId }; int newId = client.SaveQuestion(dTOQuestionstion); string answer = client.AddQuestionIdInTest(testId, newId); if (answer == "succesfull") { main.Content = new AdminTestQuestions(client, mw, main, testId); } else { MessageBox.Show("Some is bad!!!"); } } else { MessageBox.Show("CountScores must be a numbe!!!"); } } else { MessageBox.Show("Please fill in all fields!!!"); } } else { MessageBox.Show("Please chose question type"); } }