public static Product GetProductFromReader(SqlDataReader reader) { return(new Product { ProductId = SQLDataHelper.GetInt(reader, "ProductId"), ArtNo = SQLDataHelper.GetString(reader, "ArtNo"), Name = SQLDataHelper.GetString(reader, "Name"), BriefDescription = SQLDataHelper.GetString(reader, "BriefDescription", string.Empty), Description = SQLDataHelper.GetString(reader, "Description", string.Empty), Photo = SQLDataHelper.GetString(reader, "Photo"), Discount = SQLDataHelper.GetDecimal(reader, "Discount"), Size = SQLDataHelper.GetString(reader, "Size"), Weight = SQLDataHelper.GetDecimal(reader, "Weight"), Ratio = SQLDataHelper.GetDouble(reader, "Ratio"), Enabled = SQLDataHelper.GetBoolean(reader, "Enabled", true), OrderByRequest = SQLDataHelper.GetBoolean(reader, "OrderByRequest"), Recomended = SQLDataHelper.GetBoolean(reader, "Recomended"), New = SQLDataHelper.GetBoolean(reader, "New"), BestSeller = SQLDataHelper.GetBoolean(reader, "Bestseller"), OnSale = SQLDataHelper.GetBoolean(reader, "OnSale"), BrandId = SQLDataHelper.GetInt(reader, "BrandID", 0), UrlPath = SQLDataHelper.GetString(reader, "UrlPath"), HirecalEnabled = SQLDataHelper.GetBoolean(reader, "HirecalEnabled"), //Added by Evgeni to add EAN and SubbrandiD EAN = SQLDataHelper.GetString(reader, "EAN"), SubBrandId = SQLDataHelper.GetInt(reader, "SubBrandID", 0), ManufactureArtNo = SQLDataHelper.GetString(reader, "ManufactureArtNo") // }); }
/// <summary> /// Get list of products by categoryId /// </summary> /// <param name="categoryId"></param> /// <param name="inDepth">param set use recurse or not</param> /// <returns></returns> public static IList <Product> GetProductsByCategoryId(int categoryId, bool inDepth) { var query = inDepth ? "SELECT * FROM [Catalog].[Product] INNER JOIN [Catalog].[ProductCategories] on ProductCategories.ProductID = Product.ProductID WHERE [ProductCategories].CategoryID IN (SELECT id FROM [Settings].[GetChildCategoryByParent](@categoryId)) AND [Product].[Enabled] = 1 AND [Product].[CategoryEnabled] = 1" : "SELECT * FROM [Catalog].[Product] INNER JOIN [Catalog].[ProductCategories] on ProductCategories.ProductID = Product.ProductID WHERE [ProductCategories].CategoryID = @categoryId AND [Product].[Enabled] = 1 AND [Product].[CategoryEnabled] = 1"; var prouducts = SQLDataAccess.ExecuteReadList(query, CommandType.Text, reader => new Product { ProductId = SQLDataHelper.GetInt(reader, "ProductId"), Name = SQLDataHelper.GetString(reader, "Name"), BriefDescription = SQLDataHelper.GetString(reader, "BriefDescription", null), Description = SQLDataHelper.GetString(reader, "Description", null), Discount = SQLDataHelper.GetFloat(reader, "Discount"), //ShippingPrice = SQLDataHelper.GetFloat(reader, "ShippingPrice"), Size = SQLDataHelper.GetString(reader, "Size"), Weight = SQLDataHelper.GetFloat(reader, "Weight"), Ratio = SQLDataHelper.GetDouble(reader, "Ratio"), Enabled = SQLDataHelper.GetBoolean(reader, "Enabled", true), Recomended = SQLDataHelper.GetBoolean(reader, "Recomended"), New = SQLDataHelper.GetBoolean(reader, "New"), BestSeller = SQLDataHelper.GetBoolean(reader, "Bestseller"), OnSale = SQLDataHelper.GetBoolean(reader, "OnSale") }, new SqlParameter("@categoryId", categoryId)); return(prouducts ?? new List <Product>()); }