Ejemplo n.º 1
0
 /// <summary>
 /// Returns a Poll object filled with the data taken from the input PollDetails
 /// </summary>
 private static Poll GetPollFromPollDetails(PollDetails record)
 {
     if (record == null)
     {
         return(null);
     }
     else
     {
         return(new Poll(record.ID, record.AddedDate, record.AddedBy,
                         record.QuestionText, record.IsCurrent,
                         record.IsArchived, record.ArchivedDate, record.Votes));
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new poll
        /// </summary>
        public static int InsertPoll(string questionText, bool isCurrent)
        {
            PollDetails record = new PollDetails(0, DateTime.Now, BizObject.CurrentUserName,
                                                 questionText, isCurrent, false, DateTime.Now, 0);
            int ret = SiteProvider.Polls.InsertPoll(record);

            BizObject.PurgeCacheItems("polls_polls_true");
            if (isCurrent)
            {
                BizObject.PurgeCacheItems("polls_poll_current");
            }
            return(ret);
        }
 /// <summary>
 /// Updates the specified poll
 /// </summary>
 public override bool UpdatePoll(PollDetails poll)
 {
     using (SqlConnection cn = new SqlConnection(this.ConnectionString))
     {
         SqlCommand cmd = new SqlCommand("tbh_Polls_UpdatePoll", cn);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.Add("@PollID", SqlDbType.Int).Value            = poll.ID;
         cmd.Parameters.Add("@QuestionText", SqlDbType.NVarChar).Value = poll.QuestionText;
         cmd.Parameters.Add("@IsCurrent", SqlDbType.Bit).Value         = poll.IsCurrent;
         cn.Open();
         int ret = ExecuteNonQuery(cmd);
         return(ret == 1);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Updates an existing poll
        /// </summary>
        public static bool UpdatePoll(int id, string questionText, bool isCurrent)
        {
            PollDetails record = new PollDetails(id, DateTime.Now, "",
                                                 questionText, isCurrent, false, DateTime.Now, 0);
            bool ret = SiteProvider.Polls.UpdatePoll(record);

            BizObject.PurgeCacheItems("polls_polls_true");
            BizObject.PurgeCacheItems("polls_poll_" + id.ToString());
            if (isCurrent)
            {
                BizObject.PurgeCacheItems("polls_poll_current");
            }
            return(ret);
        }
 /// <summary>
 /// Inserts a new poll and returns its ID
 /// </summary>
 public override int InsertPoll(PollDetails poll)
 {
     using (SqlConnection cn = new SqlConnection(this.ConnectionString))
     {
         SqlCommand cmd = new SqlCommand("tbh_Polls_InsertPoll", cn);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.Add("@AddedDate", SqlDbType.DateTime).Value    = poll.AddedDate;
         cmd.Parameters.Add("@AddedBy", SqlDbType.NVarChar).Value      = poll.AddedBy;
         cmd.Parameters.Add("@QuestionText", SqlDbType.NVarChar).Value = poll.QuestionText;
         cmd.Parameters.Add("@IsCurrent", SqlDbType.Bit).Value         = poll.IsCurrent;
         cmd.Parameters.Add("@PollID", SqlDbType.Int).Direction        = ParameterDirection.Output;
         cn.Open();
         int ret = ExecuteNonQuery(cmd);
         return((int)cmd.Parameters["@PollID"].Value);
     }
 }
 /// <summary>
 /// Updates the specified poll
 /// </summary>
 public override bool UpdatePoll(PollDetails poll)
 {
     using (SqlConnection cn = new SqlConnection(this.ConnectionString))
      {
     SqlCommand cmd = new SqlCommand("tbh_Polls_UpdatePoll", cn);
     cmd.CommandType = CommandType.StoredProcedure;
     cmd.Parameters.Add("@PollID", SqlDbType.Int).Value = poll.ID;
     cmd.Parameters.Add("@QuestionText", SqlDbType.NVarChar).Value = poll.QuestionText;
     cmd.Parameters.Add("@IsCurrent", SqlDbType.Bit).Value = poll.IsCurrent;
     cn.Open();
     int ret = ExecuteNonQuery(cmd);
     return (ret == 1);
      }
 }
 /// <summary>
 /// Inserts a new poll and returns its ID
 /// </summary>
 public override int InsertPoll(PollDetails poll)
 {
     using (SqlConnection cn = new SqlConnection(this.ConnectionString))
      {
     SqlCommand cmd = new SqlCommand("tbh_Polls_InsertPoll", cn);
     cmd.CommandType = CommandType.StoredProcedure;
     cmd.Parameters.Add("@AddedDate", SqlDbType.DateTime).Value = poll.AddedDate;
     cmd.Parameters.Add("@AddedBy", SqlDbType.NVarChar).Value = poll.AddedBy;
     cmd.Parameters.Add("@QuestionText", SqlDbType.NVarChar).Value = poll.QuestionText;
     cmd.Parameters.Add("@IsCurrent", SqlDbType.Bit).Value = poll.IsCurrent;
     cmd.Parameters.Add("@PollID", SqlDbType.Int).Direction = ParameterDirection.Output;
     cn.Open();
     int ret = ExecuteNonQuery(cmd);
     return (int)cmd.Parameters["@PollID"].Value;
      }
 }