/// <summary>
        /// Prepare paged customer role list model
        /// </summary>
        /// <param name="searchModel">Customer role search model</param>
        /// <returns>Customer role list model</returns>
        public virtual CustomerRoleListModel PrepareCustomerRoleListModel(CustomerRoleSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get customer roles
            var customerRoles = _customerService.GetAllCustomerRoles(true);

            //prepare grid model
            var model = new CustomerRoleListModel
            {
                Data = customerRoles.PaginationByRequestModel(searchModel).Select(role =>
                {
                    //fill in model values from the entity
                    var customerRoleModel = role.ToModel <CustomerRoleModel>();


                    return(customerRoleModel);
                }),
                Total = customerRoles.Count
            };

            return(model);
        }
示例#2
0
        /// <summary>
        /// Prepare paged customer role list model
        /// </summary>
        /// <param name="searchModel">Customer role search model</param>
        /// <returns>Customer role list model</returns>
        public virtual CustomerRoleListModel PrepareCustomerRoleListModel(CustomerRoleSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get customer roles
            var customerRoles = _customerService.GetAllCustomerRoles(true);

            //prepare grid model
            var model = new CustomerRoleListModel
            {
                Data = customerRoles.PaginationByRequestModel(searchModel).Select(role =>
                {
                    //fill in model values from the entity
                    var customerRoleModel = role.ToModel <CustomerRoleModel>();

                    //fill in additional values (not existing in the entity)
                    customerRoleModel.PurchasedWithProductName = _productService.GetProductById(role.PurchasedWithProductId)?.Name;

                    return(customerRoleModel);
                }),
                Total = customerRoles.Count
            };

            return(model);
        }
示例#3
0
        /// <summary>
        /// Prepare paged customer role list model
        /// </summary>
        /// <param name="searchModel">Customer role search model</param>
        /// <returns>Customer role list model</returns>
        public virtual CustomerRoleListModel PrepareCustomerRoleListModel(CustomerRoleSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get customer roles
            var customerRoles = _customerService.GetAllCustomerRoles(true).ToPagedList(searchModel);

            //prepare grid model
            var model = new CustomerRoleListModel().PrepareToGrid(searchModel, customerRoles, () =>
            {
                return(customerRoles.Select(role =>
                {
                    //fill in model values from the entity
                    var customerRoleModel = role.ToModel <CustomerRoleModel>();

                    //fill in additional values (not existing in the entity)
                    customerRoleModel.PurchasedWithProductName = _productService.GetProductById(role.PurchasedWithProductId)?.Name;

                    return customerRoleModel;
                }));
            });

            return(model);
        }
        /// <summary>
        /// Prepare customer role search model
        /// </summary>
        /// <param name="searchModel">Customer role search model</param>
        /// <returns>Customer role search model</returns>
        public virtual CustomerRoleSearchModel PrepareCustomerRoleSearchModel(CustomerRoleSearchModel searchModel)
        {
            if (searchModel == null)
                throw new ArgumentNullException(nameof(searchModel));

            //prepare page parameters
            searchModel.SetGridPageSize();

            return searchModel;
        }
        public virtual IActionResult List(CustomerRoleSearchModel searchModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers))
            {
                return(AccessDeniedKendoGridJson());
            }

            //prepare model
            var model = _customerRoleModelFactory.PrepareCustomerRoleListModel(searchModel);

            return(Json(model));
        }
        public virtual async Task <IActionResult> List(CustomerRoleSearchModel searchModel)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageCustomers))
            {
                return(await AccessDeniedDataTablesJson());
            }

            //prepare model
            var model = await _customerRoleModelFactory.PrepareCustomerRoleListModelAsync(searchModel);

            return(Json(model));
        }
示例#7
0
        /// <summary>
        /// Prepare customer role search model
        /// </summary>
        /// <param name="searchModel">Customer role search model</param>
        /// <returns>
        /// A task that represents the asynchronous operation
        /// The task result contains the customer role search model
        /// </returns>
        public virtual Task <CustomerRoleSearchModel> PrepareCustomerRoleSearchModelAsync(CustomerRoleSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //prepare page parameters
            searchModel.SetGridPageSize();

            return(Task.FromResult(searchModel));
        }