private DBCustomerAction GetCustomerActionFromReader(IDataReader dataReader) { var item = new DBCustomerAction(); item.CustomerActionId = NopSqlDataHelper.GetInt(dataReader, "CustomerActionID"); item.Name = NopSqlDataHelper.GetString(dataReader, "Name"); item.SystemKeyword = NopSqlDataHelper.GetString(dataReader, "SystemKeyword"); item.Comment = NopSqlDataHelper.GetString(dataReader, "Comment"); item.DisplayOrder = NopSqlDataHelper.GetInt(dataReader, "DisplayOrder"); return(item); }
/// <summary> /// Gets a customer action by identifier /// </summary> /// <param name="customerActionId">Customer action identifier</param> /// <returns>Customer action</returns> public override DBCustomerAction GetCustomerActionById(int customerActionId) { DBCustomerAction item = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_CustomerActionLoadByPrimaryKey"); db.AddInParameter(dbCommand, "CustomerActionID", DbType.Int32, customerActionId); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { item = GetCustomerActionFromReader(dataReader); } } return(item); }
/// <summary> /// Updates the customer action /// </summary> /// <param name="customerActionId">The customer action identifier</param> /// <param name="name">The name</param> /// <param name="systemKeyword">The system keyword</param> /// <param name="comment">The comment</param> /// <param name="displayOrder">The display order</param> /// <returns>A customer action</returns> public override DBCustomerAction UpdateCustomerAction(int customerActionId, string name, string systemKeyword, string comment, string displayOrder) { DBCustomerAction item = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_CustomerActionUpdate"); db.AddInParameter(dbCommand, "CustomerActionID", DbType.Int32, customerActionId); db.AddInParameter(dbCommand, "Name", DbType.String, name); db.AddInParameter(dbCommand, "SystemKeyword", DbType.String, systemKeyword); db.AddInParameter(dbCommand, "Comment", DbType.String, comment); db.AddInParameter(dbCommand, "DisplayOrder", DbType.Int32, displayOrder); if (db.ExecuteNonQuery(dbCommand) > 0) { item = GetCustomerActionById(customerActionId); } return(item); }