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

            //try to get a user attribute with the specified id
            var userAttribute = _userAttributeService.GetUserAttributeById(searchModel.UserAttributeId)
                                ?? throw new ArgumentException("No user attribute found with the specified id");

            //prepare model
            var model = _userAttributeModelFactory.PrepareUserAttributeValueListModel(searchModel, userAttribute);

            return(Json(model));
        }
示例#2
0
        /// <summary>
        /// Prepare user attribute value search model
        /// </summary>
        /// <param name="searchModel">User attribute value search model</param>
        /// <param name="userAttribute">User attribute</param>
        /// <returns>User attribute value search model</returns>
        protected virtual UserAttributeValueSearchModel PrepareUserAttributeValueSearchModel(UserAttributeValueSearchModel searchModel,
                                                                                             UserAttribute userAttribute)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

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

            searchModel.UserAttributeId = userAttribute.Id;

            //prepare page parameters
            searchModel.SetGridPageSize();

            return(searchModel);
        }
示例#3
0
        /// <summary>
        /// Prepare paged user attribute value list model
        /// </summary>
        /// <param name="searchModel">User attribute value search model</param>
        /// <param name="userAttribute">User attribute</param>
        /// <returns>User attribute value list model</returns>
        public virtual UserAttributeValueListModel PrepareUserAttributeValueListModel(UserAttributeValueSearchModel searchModel,
                                                                                      UserAttribute userAttribute)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

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

            //get user attribute values
            var userAttributeValues = _userAttributeService.GetUserAttributeValues(userAttribute.Id);

            //prepare list model
            var model = new UserAttributeValueListModel
            {
                //fill in model values from the entity
                Data = userAttributeValues.PaginationByRequestModel(searchModel)
                       .Select(value => value.ToModel <UserAttributeValueModel>()),
                Total = userAttributeValues.Count
            };

            return(model);
        }