/// <summary> /// Get low stock product variants /// </summary> /// <returns>Result</returns> public override DBProductVariantCollection GetLowStockProductVariants() { DBProductVariantCollection productVariantCollection = new DBProductVariantCollection(); Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_ProductVariantLoadLowStock"); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { DBProductVariant productVariant = GetProductVariantFromReader(dataReader); productVariantCollection.Add(productVariant); } } return productVariantCollection; }
private static ProductVariantCollection DBMapping(DBProductVariantCollection dbCollection) { if (dbCollection == null) return null; ProductVariantCollection collection = new ProductVariantCollection(); foreach (DBProductVariant dbItem in dbCollection) { ProductVariant item = DBMapping(dbItem); collection.Add(item); } return collection; }
/// <summary> /// Gets all product variants directly assigned to a pricelist /// </summary> /// <param name="PricelistID"></param> /// <returns></returns> public override DBProductVariantCollection GetProductVariantsByPricelistID(int PricelistID) { DBProductVariantCollection productVariantCollection = new DBProductVariantCollection(); Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_ProductVariantLoadByPricelistID"); db.AddInParameter(dbCommand, "PricelistID", DbType.Int32, PricelistID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { DBProductVariant productVariant = GetProductVariantFromReader(dataReader); productVariantCollection.Add(productVariant); } } return productVariantCollection; }