private DBPollAnswer GetPollAnswerFromReader(IDataReader dataReader) { DBPollAnswer pollAnswer = new DBPollAnswer(); pollAnswer.PollAnswerID = NopSqlDataHelper.GetInt(dataReader, "PollAnswerID"); pollAnswer.PollID = NopSqlDataHelper.GetInt(dataReader, "PollID"); pollAnswer.Name = NopSqlDataHelper.GetString(dataReader, "Name"); pollAnswer.Count = NopSqlDataHelper.GetInt(dataReader, "Count"); pollAnswer.DisplayOrder = NopSqlDataHelper.GetInt(dataReader, "DisplayOrder"); return(pollAnswer); }
private DBPollAnswer GetPollAnswerFromReader(IDataReader dataReader) { var item = new DBPollAnswer(); item.PollAnswerId = NopSqlDataHelper.GetInt(dataReader, "PollAnswerID"); item.PollId = NopSqlDataHelper.GetInt(dataReader, "PollID"); item.Name = NopSqlDataHelper.GetString(dataReader, "Name"); item.Count = NopSqlDataHelper.GetInt(dataReader, "Count"); item.DisplayOrder = NopSqlDataHelper.GetInt(dataReader, "DisplayOrder"); return(item); }
/// <summary> /// Updates the poll answer /// </summary> /// <param name="PollAnswerID">The poll answer identifier</param> /// <param name="PollID">The poll identifier</param> /// <param name="Name">The poll answer name</param> /// <param name="Count">The current count</param> /// <param name="DisplayOrder">The display order</param> /// <returns>Poll answer</returns> public override DBPollAnswer UpdatePollAnswer(int PollAnswerID, int PollID, string Name, int Count, int DisplayOrder) { DBPollAnswer pollAnswer = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_PollAnswerUpdate"); db.AddInParameter(dbCommand, "PollAnswerID", DbType.Int32, PollAnswerID); db.AddInParameter(dbCommand, "PollID", DbType.Int32, PollID); db.AddInParameter(dbCommand, "Name", DbType.String, Name); db.AddInParameter(dbCommand, "Count", DbType.Int32, Count); db.AddInParameter(dbCommand, "DisplayOrder", DbType.Int32, DisplayOrder); if (db.ExecuteNonQuery(dbCommand) > 0) { pollAnswer = GetPollAnswerByID(PollAnswerID); } return(pollAnswer); }
/// <summary> /// Gets a poll answers by poll identifier /// </summary> /// <param name="PollID">Poll identifier</param> /// <returns>Poll answer collection</returns> public override DBPollAnswerCollection GetPollAnswersByPollID(int PollID) { DBPollAnswerCollection pollAnswerCollection = new DBPollAnswerCollection(); Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_PollAnswerLoadByPollID"); db.AddInParameter(dbCommand, "PollID", DbType.Int32, PollID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { DBPollAnswer pollAnswer = GetPollAnswerFromReader(dataReader); pollAnswerCollection.Add(pollAnswer); } } return(pollAnswerCollection); }
/// <summary> /// Updates the poll answer /// </summary> /// <param name="pollAnswerId">The poll answer identifier</param> /// <param name="pollId">The poll identifier</param> /// <param name="name">The poll answer name</param> /// <param name="count">The current count</param> /// <param name="displayOrder">The display order</param> /// <returns>Poll answer</returns> public override DBPollAnswer UpdatePollAnswer(int pollAnswerId, int pollId, string name, int count, int displayOrder) { DBPollAnswer item = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_PollAnswerUpdate"); db.AddInParameter(dbCommand, "PollAnswerID", DbType.Int32, pollAnswerId); db.AddInParameter(dbCommand, "PollID", DbType.Int32, pollId); db.AddInParameter(dbCommand, "Name", DbType.String, name); db.AddInParameter(dbCommand, "Count", DbType.Int32, count); db.AddInParameter(dbCommand, "DisplayOrder", DbType.Int32, displayOrder); if (db.ExecuteNonQuery(dbCommand) > 0) { item = GetPollAnswerById(pollAnswerId); } return(item); }
/// <summary> /// Gets a poll answer /// </summary> /// <param name="PollAnswerID">Poll answer identifier</param> /// <returns>Poll answer</returns> public override DBPollAnswer GetPollAnswerByID(int PollAnswerID) { DBPollAnswer pollAnswer = null; if (PollAnswerID == 0) { return(pollAnswer); } Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_PollAnswerLoadByPrimaryKey"); db.AddInParameter(dbCommand, "PollAnswerID", DbType.Int32, PollAnswerID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { pollAnswer = GetPollAnswerFromReader(dataReader); } } return(pollAnswer); }