示例#1
0
        public virtual IActionResult ValueList(TaskAttributeValueSearchModel searchModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedKendoGridJson());
            }

            //try to get a customer attribute with the specified id
            var taskAttribute = _taskAttributeService.GetTaskAttributeById(searchModel.TaskAttributeId)
                                ?? throw new ArgumentException("No task attribute found with the specified id");

            //prepare model
            var model = _taskAttributeModelFactory.PrepareTaskAttributeValueListModel(searchModel, taskAttribute);

            return(Json(model));
        }
        protected virtual TaskAttributeValueSearchModel PrepareTaskAttributeValueSearchModel(TaskAttributeValueSearchModel searchModel,
                                                                                             TaskAttribute taskAttribute)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

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

            searchModel.TaskAttributeId = taskAttribute.Id;

            //prepare page parameters
            searchModel.SetGridPageSize();

            return(searchModel);
        }
        public virtual TaskAttributeValueListModel PrepareTaskAttributeValueListModel(TaskAttributeValueSearchModel searchModel, TaskAttribute taskAttribute)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

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

            var taskAttributeValues = _taskAttributeService.GetTaskAttributeValues(taskAttribute.Id);

            var model = new TaskAttributeValueListModel
            {
                //fill in model values from the entity
                Data = taskAttributeValues.PaginationByRequestModel(searchModel)
                       .Select(value => value.ToModel <TaskAttributeValueModel>()),
                Total = taskAttributeValues.Count
            };

            return(model);
        }