Esempio n. 1
0
        protected void saveButton_Click(object sender, EventArgs e)
        {
            VoteCast voteCast = new VoteCast();

            voteCast.VoterId     = voterIdTextBox.Text;
            voteCast.CandidateId = Convert.ToInt32(symbolDropDownList.SelectedValue);
            CastVoteManager castVoteManager = new CastVoteManager();
            bool            isSuccess       = castVoteManager.Save(voteCast);
        }
        public int Save(VoteCast voteCast)
        {
            SqlConnection connection = new SqlConnection(connectionString);

            string query = "INSERT INTO CastVote VALUES('" + voteCast.VoterId + "', '" + voteCast.CandidateId + "')";

            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();

            int rowAffected = command.ExecuteNonQuery();

            connection.Close();

            return(rowAffected);
        }
Esempio n. 3
0
 public bool Save(VoteCast voteCast)
 {
     return(castVoteGateway.Save(voteCast) > 0);
 }