public static BallotCollection GetBallots(Motion motion) { var result = new BallotCollection(); var sql = CreateCommand(); sql.CommandText = @"SELECT id,motionId,moderatorId,choice FROM ballots WHERE motionId = ?motionId"; var pId = sql.CreateParameter(); pId.ParameterName = "?motionId"; pId.Value = motion.Id; sql.Parameters.Add(pId); using (var db = CreateConnection()) { db.Open(); sql.Connection = db; sql.Prepare(); var rs = sql.ExecuteReader(); while (rs.Read()) { result.Add(new Ballot { Id = rs.GetInt32(0), Motion = GetMotion(rs.GetInt32(1)), Moderator = GetModerator(rs.GetInt32(2)), Choice = (Choice)rs.GetInt32(3) }); } db.Close(); } return(result); }
public Motion() { this.Votes = new BallotCollection(); this.Text = ""; this.PostUrl = ""; }