コード例 #1
0
 public static void CreateRelationship(ProblemQuestionRelationship relationship)
 {
     _relationships.Add(relationship);
     relationship.Problem.Relationships.Add(relationship);
     relationship.Question.Relationships.Add(relationship);
     _session.Save(_relationships);
     Debug.Print("Relationship between {0} and {1} saved", relationship.Problem.ShortName,
         relationship.Question.QuestionText);
 }
コード例 #2
0
 private void simpleButton1_Click(object sender, EventArgs e)
 {
     var newQuestion = new Question(newQuestionText.Text);
     DataBaseContext.CreateQuestion(newQuestion);
     var relation1 = new ProblemQuestionRelationship(_problem1, newQuestion, Int32.Parse(prob1Yes.Text),
         Int32.Parse(prob1No.Text));
     var relation2 = new ProblemQuestionRelationship(_problem2, newQuestion, Int32.Parse(prob2Yes.Text),
         Int32.Parse(prob2No.Text));
     DataBaseContext.CreateRelationship(relation1);
     DataBaseContext.CreateRelationship(relation2);
     this.Close();
 }
コード例 #3
0
 public static void ConfirmedAssumption()
 {
     ProblemRatio problemRatio = ProblemRatios[0];
     foreach (var askedQuestion in _askedQuestions)
     {
         if (problemRatio.Problem.Relationships.Any(r => r.Question.Oid == askedQuestion.Item1.Oid))
         {
             ProblemQuestionRelationship relation =
                 problemRatio.Problem.Relationships.First(r => r.Question.Oid == askedQuestion.Item1.Oid);
             if (!askedQuestion.Item2.HasValue)
             {
                 continue;
             }
             if (askedQuestion.Item2.Value) // Положительный ответ на вопрос
             {
                 relation.PossibleAnswersCount++;
             }
             else
             {
                 relation.NegativeAnswersCount++;
             }
             DataBaseContext.UpdateRelation(relation);
         }
         else
         {
             var newRelation = new ProblemQuestionRelationship(problemRatio.Problem, askedQuestion.Item1);
             if (!askedQuestion.Item2.HasValue)
             {
                 continue;
             }
             if (askedQuestion.Item2.Value) // Положительный ответ на вопрос
             {
                 newRelation.PossibleAnswersCount++;
             }
             else
             {
                 newRelation.NegativeAnswersCount++;
             }
             DataBaseContext.CreateRelationship(newRelation);
         }
     }
     DataBaseContext.UpdateProblem(problemRatio.Problem, true);
 }
コード例 #4
0
 public static void UpdateRelation(ProblemQuestionRelationship relationship)
 {
     _session.Save(relationship);
 }