/// <summary> /// Inserts a checkout attribute /// </summary> /// <param name="name">Name</param> /// <param name="textPrompt">Text prompt</param> /// <param name="isRequired">Value indicating whether the entity is required</param> /// <param name="shippableProductRequired">Value indicating whether shippable products are required in order to display this attribute</param> /// <param name="isTaxExempt">Value indicating whether the attribute is marked as tax exempt</param> /// <param name="taxCategoryId">Tax category identifier</param> /// <param name="attributeControlTypeId">Attribute control type identifier</param> /// <param name="displayOrder">Display order</param> /// <returns>Checkout attribute</returns> public override DBCheckoutAttribute InsertCheckoutAttribute(string name, string textPrompt, bool isRequired, bool shippableProductRequired, bool isTaxExempt, int taxCategoryId, int attributeControlTypeId, int displayOrder) { DBCheckoutAttribute item = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_CheckoutAttributeInsert"); db.AddOutParameter(dbCommand, "CheckoutAttributeID", DbType.Int32, 0); db.AddInParameter(dbCommand, "Name", DbType.String, name); db.AddInParameter(dbCommand, "TextPrompt", DbType.String, textPrompt); db.AddInParameter(dbCommand, "IsRequired", DbType.Boolean, isRequired); db.AddInParameter(dbCommand, "ShippableProductRequired", DbType.Boolean, shippableProductRequired); db.AddInParameter(dbCommand, "IsTaxExempt", DbType.Boolean, isTaxExempt); db.AddInParameter(dbCommand, "TaxCategoryID", DbType.Int32, taxCategoryId); db.AddInParameter(dbCommand, "AttributeControlTypeID", DbType.Int32, attributeControlTypeId); db.AddInParameter(dbCommand, "DisplayOrder", DbType.Int32, displayOrder); if (db.ExecuteNonQuery(dbCommand) > 0) { int checkoutAttributeId = Convert.ToInt32(db.GetParameterValue(dbCommand, "@CheckoutAttributeID")); item = GetCheckoutAttributeById(checkoutAttributeId, 0); } return(item); }
private DBCheckoutAttribute GetCheckoutAttributeFromReader(IDataReader dataReader) { var item = new DBCheckoutAttribute(); item.CheckoutAttributeId = NopSqlDataHelper.GetInt(dataReader, "CheckoutAttributeID"); item.Name = NopSqlDataHelper.GetString(dataReader, "Name"); item.TextPrompt = NopSqlDataHelper.GetString(dataReader, "TextPrompt"); item.IsRequired = NopSqlDataHelper.GetBoolean(dataReader, "IsRequired"); item.ShippableProductRequired = NopSqlDataHelper.GetBoolean(dataReader, "ShippableProductRequired"); item.IsTaxExempt = NopSqlDataHelper.GetBoolean(dataReader, "IsTaxExempt"); item.TaxCategoryId = NopSqlDataHelper.GetInt(dataReader, "TaxCategoryID"); item.AttributeControlTypeId = NopSqlDataHelper.GetInt(dataReader, "AttributeControlTypeID"); item.DisplayOrder = NopSqlDataHelper.GetInt(dataReader, "DisplayOrder"); return(item); }
/// <summary> /// Gets a checkout attribute /// </summary> /// <param name="checkoutAttributeId">Checkout attribute identifier</param> /// <param name="languageId">Language identifier</param> /// <returns>Checkout attribute</returns> public override DBCheckoutAttribute GetCheckoutAttributeById(int checkoutAttributeId, int languageId) { DBCheckoutAttribute item = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_CheckoutAttributeLoadByPrimaryKey"); db.AddInParameter(dbCommand, "CheckoutAttributeID", DbType.Int32, checkoutAttributeId); db.AddInParameter(dbCommand, "LanguageID", DbType.Int32, languageId); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { item = GetCheckoutAttributeFromReader(dataReader); } } return(item); }