private DBProductCategory GetProductCategoryFromReader(IDataReader dataReader) { DBProductCategory productCategory = new DBProductCategory(); productCategory.ProductCategoryID = NopSqlDataHelper.GetInt(dataReader, "ProductCategoryID"); productCategory.ProductID = NopSqlDataHelper.GetInt(dataReader, "ProductID"); productCategory.CategoryID = NopSqlDataHelper.GetInt(dataReader, "CategoryID"); productCategory.IsFeaturedProduct = NopSqlDataHelper.GetBoolean(dataReader, "IsFeaturedProduct"); productCategory.DisplayOrder = NopSqlDataHelper.GetInt(dataReader, "DisplayOrder"); return(productCategory); }
private DBProductCategory GetProductCategoryFromReader(IDataReader dataReader) { var item = new DBProductCategory(); item.ProductCategoryId = NopSqlDataHelper.GetInt(dataReader, "ProductCategoryID"); item.ProductId = NopSqlDataHelper.GetInt(dataReader, "ProductID"); item.CategoryId = NopSqlDataHelper.GetInt(dataReader, "CategoryID"); item.IsFeaturedProduct = NopSqlDataHelper.GetBoolean(dataReader, "IsFeaturedProduct"); item.DisplayOrder = NopSqlDataHelper.GetInt(dataReader, "DisplayOrder"); return(item); }
/// <summary> /// Updates the product category mapping /// </summary> /// <param name="ProductCategoryID">Product category mapping identifier</param> /// <param name="ProductID">Product identifier</param> /// <param name="CategoryID">Category identifier</param> /// <param name="IsFeaturedProduct">A value indicating whether the product is featured</param> /// <param name="DisplayOrder">The display order</param> /// <returns>Product category mapping </returns> public override DBProductCategory UpdateProductCategory(int ProductCategoryID, int ProductID, int CategoryID, bool IsFeaturedProduct, int DisplayOrder) { DBProductCategory productCategory = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_Product_Category_MappingUpdate"); db.AddInParameter(dbCommand, "ProductCategoryID", DbType.Int32, ProductCategoryID); db.AddInParameter(dbCommand, "ProductID", DbType.Int32, ProductID); db.AddInParameter(dbCommand, "CategoryID", DbType.Int32, CategoryID); db.AddInParameter(dbCommand, "IsFeaturedProduct", DbType.Boolean, IsFeaturedProduct); db.AddInParameter(dbCommand, "DisplayOrder", DbType.Int32, DisplayOrder); if (db.ExecuteNonQuery(dbCommand) > 0) { productCategory = GetProductCategoryByID(ProductCategoryID); } return(productCategory); }
/// <summary> /// Gets a product category mapping collection /// </summary> /// <param name="ProductID">Product identifier</param> /// <param name="showHidden">A value indicating whether to show hidden records</param> /// <returns>Product category mapping collection</returns> public override DBProductCategoryCollection GetProductCategoriesByProductID(int ProductID, bool showHidden) { DBProductCategoryCollection productCategoryCollection = new DBProductCategoryCollection(); Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_Product_Category_MappingLoadByProductID"); db.AddInParameter(dbCommand, "ProductID", DbType.Int32, ProductID); db.AddInParameter(dbCommand, "ShowHidden", DbType.Boolean, showHidden); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { DBProductCategory productCategory = GetProductCategoryFromReader(dataReader); productCategoryCollection.Add(productCategory); } } return(productCategoryCollection); }
/// <summary> /// Updates the product category mapping /// </summary> /// <param name="productCategoryId">Product category mapping identifier</param> /// <param name="productId">Product identifier</param> /// <param name="categoryId">Category identifier</param> /// <param name="isFeaturedProduct">A value indicating whether the product is featured</param> /// <param name="displayOrder">The display order</param> /// <returns>Product category mapping </returns> public override DBProductCategory UpdateProductCategory(int productCategoryId, int productId, int categoryId, bool isFeaturedProduct, int displayOrder) { DBProductCategory item = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_Product_Category_MappingUpdate"); db.AddInParameter(dbCommand, "ProductCategoryID", DbType.Int32, productCategoryId); db.AddInParameter(dbCommand, "ProductID", DbType.Int32, productId); db.AddInParameter(dbCommand, "CategoryID", DbType.Int32, categoryId); db.AddInParameter(dbCommand, "IsFeaturedProduct", DbType.Boolean, isFeaturedProduct); db.AddInParameter(dbCommand, "DisplayOrder", DbType.Int32, displayOrder); if (db.ExecuteNonQuery(dbCommand) > 0) { item = GetProductCategoryById(productCategoryId); } return(item); }
/// <summary> /// Gets a product category mapping /// </summary> /// <param name="ProductCategoryID">Product category mapping identifier</param> /// <returns>Product category mapping</returns> public override DBProductCategory GetProductCategoryByID(int ProductCategoryID) { DBProductCategory productCategory = null; if (ProductCategoryID == 0) { return(productCategory); } Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_Product_Category_MappingLoadByPrimaryKey"); db.AddInParameter(dbCommand, "ProductCategoryID", DbType.Int32, ProductCategoryID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { productCategory = GetProductCategoryFromReader(dataReader); } } return(productCategory); }