/// <summary> /// Gets all discounts /// </summary> /// <param name="showHidden">A value indicating whether to show hidden records</param> /// <param name="discountTypeId">Discount type identifier; null to load all discount</param> /// <returns>Discount collection</returns> public override DBDiscountCollection GetAllDiscounts(bool showHidden, int?discountTypeId) { var result = new DBDiscountCollection(); Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_DiscountLoadAll"); db.AddInParameter(dbCommand, "ShowHidden", DbType.Boolean, showHidden); if (discountTypeId.HasValue) { db.AddInParameter(dbCommand, "DiscountTypeID", DbType.Int32, discountTypeId.Value); } else { db.AddInParameter(dbCommand, "DiscountTypeID", DbType.Int32, null); } using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { var item = GetDiscountFromReader(dataReader); result.Add(item); } } return(result); }
/// <summary> /// Gets a discount collection of a category /// </summary> /// <param name="categoryId">Category identifier</param> /// <param name="showHidden">A value indicating whether to show hidden records</param> /// <returns>Discount collection</returns> public override DBDiscountCollection GetDiscountsByCategoryId(int categoryId, bool showHidden) { var result = new DBDiscountCollection(); Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_DiscountLoadByCategoryID"); db.AddInParameter(dbCommand, "CategoryID", DbType.Int32, categoryId); db.AddInParameter(dbCommand, "ShowHidden", DbType.Boolean, showHidden); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { var item = GetDiscountFromReader(dataReader); result.Add(item); } } return(result); }
/// <summary> /// Gets a discount collection of a product variant /// </summary> /// <param name="ProductVariantID">Product variant identifier</param> /// <param name="showHidden">A value indicating whether to show hidden records</param> /// <returns>Discount collection</returns> public override DBDiscountCollection GetDiscountsByProductVariantID(int ProductVariantID, bool showHidden) { DBDiscountCollection discountCollection = new DBDiscountCollection(); Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_DiscountLoadByProductVariantID"); db.AddInParameter(dbCommand, "ShowHidden", DbType.Boolean, showHidden); db.AddInParameter(dbCommand, "ProductVariantID", DbType.Int32, ProductVariantID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { DBDiscount discount = GetDiscountFromReader(dataReader); discountCollection.Add(discount); } } return(discountCollection); }
/// <summary> /// Gets a discount collection of a category /// </summary> /// <param name="CategoryID">Category identifier</param> /// <param name="showHidden">A value indicating whether to show hidden records</param> /// <returns>Discount collection</returns> public override DBDiscountCollection GetDiscountsByCategoryID(int CategoryID, bool showHidden) { DBDiscountCollection discountCollection = new DBDiscountCollection(); Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_DiscountLoadByCategoryID"); db.AddInParameter(dbCommand, "ShowHidden", DbType.Boolean, showHidden); db.AddInParameter(dbCommand, "CategoryID", DbType.Int32, CategoryID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { DBDiscount discount = GetDiscountFromReader(dataReader); discountCollection.Add(discount); } } return discountCollection; }
/// <summary> /// Gets all discounts /// </summary> /// <param name="showHidden">A value indicating whether to show hidden records</param> /// <param name="DiscountTypeID">Discount type identifier; null to load all discount</param> /// <returns>Discount collection</returns> public override DBDiscountCollection GetAllDiscounts(bool showHidden, int? DiscountTypeID) { DBDiscountCollection discountCollection = new DBDiscountCollection(); Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_DiscountLoadAll"); db.AddInParameter(dbCommand, "ShowHidden", DbType.Boolean, showHidden); if (DiscountTypeID.HasValue) db.AddInParameter(dbCommand, "DiscountTypeID", DbType.Int32, DiscountTypeID.Value); else db.AddInParameter(dbCommand, "DiscountTypeID", DbType.Int32, null); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { DBDiscount discount = GetDiscountFromReader(dataReader); discountCollection.Add(discount); } } return discountCollection; }