protected void btnVote_Click(object sender, EventArgs e) { if (CurrentUserSession != null && !String.IsNullOrEmpty(rblChoices.SelectedValue)) { int choiceID = Convert.ToInt32(rblChoices.SelectedValue); GroupPollsAnwer answer = new GroupPollsAnwer(TopicID, CurrentUserSession.Username, choiceID); answer.Save(); } }
/// <summary> /// Fetches group poll answers by specified parameters. /// It returns an empty array if there are no group poll answers in DB by specified arguments. /// If these arguments are null it returns all group poll answers from DB. /// </summary> /// <param name="groupTopicID">The group topic ID.</param> /// <param name="username">The username.</param> /// <param name="groupPollChoiceID">The group poll choice ID.</param> /// <returns></returns> private static GroupPollsAnwer[] Fetch(int? groupTopicID, string username, int? groupPollChoiceID) { //using (var conn = Config.DB.Open()) { List <GroupPollsAnwer> lGroupPollsAnswer = new List<GroupPollsAnwer>(); using (var reader = SqlHelper.GetDB().ExecuteReader("FetchGroupPollsAnswers", groupTopicID, username, groupPollChoiceID)) { while (reader.Read()) { GroupPollsAnwer groupPollsAnswer = new GroupPollsAnwer(); groupPollsAnswer.groupTopicID = (int) reader["GroupTopicID"]; groupPollsAnswer.username = (string) reader["Username"]; groupPollsAnswer.groupPollChoiceID = (int) reader["GroupPollChoiceID"]; lGroupPollsAnswer.Add(groupPollsAnswer); } reader.Close(); } return lGroupPollsAnswer.ToArray(); } }