public virtual async Task<IActionResult> ValueList(CustomerAttributeValueSearchModel searchModel)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageSettings))
                return await AccessDeniedDataTablesJson();

            //try to get a customer attribute with the specified id
            var customerAttribute = await _customerAttributeService.GetCustomerAttributeByIdAsync(searchModel.CustomerAttributeId)
                ?? throw new ArgumentException("No customer attribute found with the specified id");

            //prepare model
            var model = await _customerAttributeModelFactory.PrepareCustomerAttributeValueListModelAsync(searchModel, customerAttribute);

            return Json(model);
        }
        public virtual IActionResult ValueList(CustomerAttributeValueSearchModel searchModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedKendoGridJson());
            }

            //try to get a customer attribute with the specified id
            var customerAttribute = _customerAttributeService.GetCustomerAttributeById(searchModel.CustomerAttributeId)
                                    ?? throw new ArgumentException("No customer attribute found with the specified id");

            //prepare model
            var model = _customerAttributeModelFactory.PrepareCustomerAttributeValueListModel(searchModel, customerAttribute);

            return(Json(model));
        }
示例#3
0
        /// <summary>
        /// Prepare customer attribute value search model
        /// </summary>
        /// <param name="searchModel">Customer attribute value search model</param>
        /// <param name="customerAttribute">Customer attribute</param>
        /// <returns>Customer attribute value search model</returns>
        protected virtual CustomerAttributeValueSearchModel PrepareCustomerAttributeValueSearchModel(CustomerAttributeValueSearchModel searchModel,
                                                                                                     CustomerAttribute customerAttribute)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            if (customerAttribute == null)
            {
                throw new ArgumentNullException(nameof(customerAttribute));
            }

            searchModel.CustomerAttributeId = customerAttribute.Id;

            //prepare page parameters
            searchModel.SetGridPageSize();

            return(searchModel);
        }
示例#4
0
        /// <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);
        }