/// <summary> /// Prepare paged vendor attribute list model /// </summary> /// <param name="searchModel">Vendor attribute search model</param> /// <returns>Vendor attribute list model</returns> public virtual VendorAttributeListModel PrepareVendorAttributeListModel(VendorAttributeSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get vendor attributes var vendorAttributes = _vendorAttributeService.GetAllVendorAttributes(); //prepare list model var model = new VendorAttributeListModel { Data = vendorAttributes.PaginationByRequestModel(searchModel).Select(attribute => { //fill in model values from the entity var attributeModel = attribute.ToModel <VendorAttributeModel>(); //fill in additional values (not existing in the entity) attributeModel.AttributeControlTypeName = _localizationService.GetLocalizedEnum(attribute.AttributeControlType); return(attributeModel); }), Total = vendorAttributes.Count }; return(model); }
/// <summary> /// Prepare paged vendor attribute list model /// </summary> /// <param name="searchModel">Vendor attribute search model</param> /// <returns>Vendor attribute list model</returns> public virtual VendorAttributeListModel PrepareVendorAttributeListModel(VendorAttributeSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get vendor attributes var vendorAttributes = _vendorAttributeService.GetAllVendorAttributes().ToPagedList(searchModel); //prepare list model var model = new VendorAttributeListModel().PrepareToGrid(searchModel, vendorAttributes, () => { return(vendorAttributes.Select(attribute => { //fill in model values from the entity var attributeModel = attribute.ToModel <VendorAttributeModel>(); //fill in additional values (not existing in the entity) attributeModel.AttributeControlTypeName = _localizationService.GetLocalizedEnum(attribute.AttributeControlType); return attributeModel; })); }); return(model); }