Пример #1
0
        public bool Equals(Quiz other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }
            if (ReferenceEquals(this, other))
            {
                return true;
            }

            return base.Equals(other) && Answer.Equals(other.Answer) && Question.Equals(other.Question);
        }
 public void SetQuestion(Quiz q)
 {
     _view.Question.Text = q.Question;
     _view.Answer.Text = q.Answer;
 }
Пример #3
0
 private Citizen PriLoadCitizen(int id)
 {
     Contract.Requires(this.Transacting(), "This method must be performed in a transaction.");
     Contract.Requires(PriExistsWithId("person", id), "Person must exist in the database to be loaded.");
     Contract.Requires(HasValidCpr(id), "A citizen must have a valid CPR number");
     Contract.Ensures(Contract.Result<Citizen>() != null);
     MySqlCommand command = Prepare("SELECT " +
                                    "    *, v.name venue_name, v.address venue_address " +
                                    "FROM " +
                                    "    person p " +
                                    "    LEFT JOIN " +
                                    "        voting_venue v " +
                                    "    ON " +
                                    "        v.id=p.voting_venue_id " +
                                    "WHERE " +
                                    "    p.id=@id");
     command.Parameters.AddWithValue("@id", id);
     Citizen c = null;
     Query(command, rdr =>
     {
         rdr.Read();
         c = new Citizen(id, rdr.GetString("cpr"), rdr.GetInt32("has_voted") != 0);
         c.EligibleToVote = rdr.GetInt16("eligible_to_vote") == 1;
         DoIfNotDbNull(rdr, "voting_venue_id", label =>
         {
             c.VotingPlace = new VotingVenue(
                 rdr.GetInt32(label),
                 rdr.GetString("venue_name"),
                 rdr.GetString("venue_address"));
         });
         DoIfNotDbNull(rdr, "name", lbl => { c.Name = rdr.GetString(lbl); });
         DoIfNotDbNull(rdr, "address", lbl => { c.Address = rdr.GetString(lbl); });
         DoIfNotDbNull(rdr, "place_of_birth", lbl => { c.PlaceOfBirth = rdr.GetString(lbl); });
         DoIfNotDbNull(rdr, "passport_number", lbl => { c.PassportNumber = rdr.GetString(lbl); });
     });
     MySqlCommand findQuestions = Prepare("SELECT * FROM quiz WHERE person_id=@id");
     findQuestions.Parameters.AddWithValue("@id", id);
     Query(findQuestions, rdr =>
     {
         while (rdr.Read())
         {
             Quiz q = new Quiz(rdr.GetString("question"), rdr.GetString("answer"));
             c.SecurityQuestions.Add(q);
         }
     });
     return c;
 }