/// <summary> /// Prepare paged product list model to add to the category /// </summary> /// <param name="searchModel">Product search model to add to the category</param> /// <returns>Product list model to add to the category</returns> public virtual AddProductToCategoryListModel PrepareAddProductToCategoryListModel(AddProductToCategorySearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get products var products = _productService.SearchProducts(showHidden: true, categoryIds: new List <int> { searchModel.SearchCategoryId }, manufacturerId: searchModel.SearchManufacturerId, storeId: searchModel.SearchStoreId, vendorId: searchModel.SearchVendorId, productType: searchModel.SearchProductTypeId > 0 ? (ProductType?)searchModel.SearchProductTypeId : null, keywords: searchModel.SearchProductName, pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize); //prepare grid model var model = new AddProductToCategoryListModel { //fill in model values from the entity Data = products.Select(product => product.ToModel <ProductModel>()), Total = products.TotalCount }; return(model); }
/// <summary> /// Prepare paged product list model to add to the category /// </summary> /// <param name="searchModel">Product search model to add to the category</param> /// <returns>Product list model to add to the category</returns> public virtual AddProductToCategoryListModel PrepareAddProductToCategoryListModel(AddProductToCategorySearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get products var products = _productService.SearchProducts(showHidden: true, categoryIds: new List <int> { searchModel.SearchCategoryId }, manufacturerId: searchModel.SearchManufacturerId, storeId: searchModel.SearchStoreId, vendorId: searchModel.SearchVendorId, productType: searchModel.SearchProductTypeId > 0 ? (ProductType?)searchModel.SearchProductTypeId : null, keywords: searchModel.SearchProductName, pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize); //prepare grid model var model = new AddProductToCategoryListModel().PrepareToGrid(searchModel, products, () => { return(products.Select(product => { var productModel = product.ToModel <ProductModel>(); productModel.SeName = _urlRecordService.GetSeName(product, 0, true, false); return productModel; })); }); return(model); }