/// <summary> /// Prepare paged product attribute list model /// </summary> /// <param name="searchModel">Product attribute search model</param> /// <returns>Product attribute list model</returns> public virtual async Task <ProductAttributeListModel> PrepareProductAttributeListModelAsync(ProductAttributeSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get product attributes var productAttributes = await _productAttributeService .GetAllProductAttributesAsync(pageIndex : searchModel.Page - 1, pageSize : searchModel.PageSize); //prepare list model var model = new ProductAttributeListModel().PrepareToGrid(searchModel, productAttributes, () => { //fill in model values from the entity return(productAttributes.Select(attribute => attribute.ToModel <ProductAttributeModel>())); }); return(model); }
/// <summary> /// Prepare paged product attribute list model /// </summary> /// <param name="searchModel">Product attribute search model</param> /// <returns>Product attribute list model</returns> public virtual ProductAttributeListModel PrepareProductAttributeListModel(ProductAttributeSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get product attributes var productAttributes = _productAttributeService .GetAllProductAttributes(pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize); //prepare list model var model = new ProductAttributeListModel { //fill in model values from the entity Data = productAttributes.Select(attribute => attribute.ToModel <ProductAttributeModel>()), Total = productAttributes.TotalCount }; return(model); }