/// <summary> /// Prepare paged product list model to add to the manufacturer /// </summary> /// <param name="searchModel">Product search model to add to the manufacturer</param> /// <returns>Product list model to add to the manufacturer</returns> public virtual AddProductToManufacturerListModel PrepareAddProductToManufacturerListModel(AddProductToManufacturerSearchModel 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 AddProductToManufacturerListModel { //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 manufacturer /// </summary> /// <param name="searchModel">Product search model to add to the manufacturer</param> /// <returns>Product list model to add to the manufacturer</returns> public virtual AddProductToManufacturerListModel PrepareAddProductToManufacturerListModel(AddProductToManufacturerSearchModel 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 AddProductToManufacturerListModel().PrepareToGrid(searchModel, products, () => { return(products.Select(product => { var productModel = product.ToModel <ProductModel>(); productModel.SeName = _urlRecordService.GetSeName(product, 0, true, false); return productModel; })); }); return(model); }