/// <summary> /// Prepare paged customer attribute value list model /// </summary> /// <param name="searchModel">Customer attribute value search model</param> /// <param name="customerAttribute">Customer attribute</param> /// <returns>Customer attribute value list model</returns> public virtual async Task <CustomerAttributeValueListModel> PrepareCustomerAttributeValueListModelAsync(CustomerAttributeValueSearchModel searchModel, CustomerAttribute customerAttribute) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } if (customerAttribute == null) { throw new ArgumentNullException(nameof(customerAttribute)); } //get customer attribute values var customerAttributeValues = (await _customerAttributeService .GetCustomerAttributeValuesAsync(customerAttribute.Id)).ToPagedList(searchModel); //prepare list model var model = new CustomerAttributeValueListModel().PrepareToGrid(searchModel, customerAttributeValues, () => { //fill in model values from the entity return(customerAttributeValues.Select(value => value.ToModel <CustomerAttributeValueModel>())); }); return(model); }
/// <summary> /// Prepare paged customer attribute value list model /// </summary> /// <param name="searchModel">Customer attribute value search model</param> /// <param name="customerAttribute">Customer attribute</param> /// <returns>Customer attribute value list model</returns> public virtual CustomerAttributeValueListModel PrepareCustomerAttributeValueListModel(CustomerAttributeValueSearchModel searchModel, CustomerAttribute customerAttribute) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } if (customerAttribute == null) { throw new ArgumentNullException(nameof(customerAttribute)); } //get customer attribute values var customerAttributeValues = _customerAttributeService.GetCustomerAttributeValues(customerAttribute.Id); //prepare list model var model = new CustomerAttributeValueListModel { //fill in model values from the entity Data = customerAttributeValues.PaginationByRequestModel(searchModel) .Select(value => value.ToModel <CustomerAttributeValueModel>()), Total = customerAttributeValues.Count }; return(model); }