public static ProductCollectionPaged SetProductDataDistinct(int pageNumber, int pageSize, List <GetAllProductsByDepartmentDistinct_Result> allProducts) { ProductCollectionPaged collection = new ProductCollectionPaged(); List <Product> temp = new List <Product>(); using (FreeMarketEntities db = new FreeMarketEntities()) { if (allProducts != null && allProducts.Count > 0) { foreach (GetAllProductsByDepartmentDistinct_Result product in allProducts) { Product prodTemp = Product.GetShallowProduct(product.ProductNumber, product.SupplierNumber); prodTemp.MinPrice = product.minPrice; prodTemp.MaxPrice = product.maxPrice; PopularProduct pp = db.PopularProducts.Where(c => c.ProductNumber == prodTemp.ProductNumber && c.SupplierNumber == prodTemp.SupplierNumber).FirstOrDefault(); if (pp != null) { prodTemp.NumberSold = pp.NumberSold ?? 0; } if (prodTemp != null) { temp.Add(prodTemp); } } } collection.Products = (PagedList <Product>)temp.ToPagedList(pageNumber, pageSize); return(collection); } }
public static ProductCollectionPaged SetAllProductDataDistinctFilter(int pageNumber, int pageSize, List <GetAllProductsDistinctFilter_Result> allProducts) { ProductCollectionPaged collection = new ProductCollectionPaged(); List <Product> temp = new List <Product>(); using (FreeMarketEntities db = new FreeMarketEntities()) { if (allProducts != null && allProducts.Count > 0) { foreach (GetAllProductsDistinctFilter_Result product in allProducts) { Product prodTemp = Product.GetShallowProduct((int)product.ProductNumber, (int)product.SupplierNumber); prodTemp.MinPrice = product.minPrice; prodTemp.MaxPrice = product.maxPrice; if (prodTemp != null) { temp.Add(prodTemp); } } } collection.Products = (PagedList <Product>)temp.ToPagedList(pageNumber, pageSize); return(collection); } }
public static ProductCollectionPaged GetProductsByDepartment(int pageNumber, int pageSize, int departmentNumber) { ProductCollectionPaged departmentProducts = new ProductCollectionPaged(); List <GetAllProductsByDepartmentDistinct_Result> result = new List <GetAllProductsByDepartmentDistinct_Result>(); using (FreeMarketEntities db = new FreeMarketEntities()) { result = db.GetAllProductsByDepartmentDistinct(departmentNumber) .ToList(); departmentProducts = SetProductDataDistinct(pageNumber, pageSize, result); return(departmentProducts); } }
public static ProductCollectionPaged GetProductsFiltered(int pageNumber, int pageSize, string filter) { ProductCollectionPaged products = new ProductCollectionPaged(); List <GetAllProductsDistinctFilter_Result> result = new List <GetAllProductsDistinctFilter_Result>(); if (string.IsNullOrEmpty(filter)) { return(products); } using (FreeMarketEntities db = new FreeMarketEntities()) { result = db.GetAllProductsDistinctFilter(filter) .ToList(); products = SetAllProductDataDistinctFilter(pageNumber, pageSize, result); return(products); } }