コード例 #1
0
        /// <summary>
        /// Prepare paged product list model to add to the category
        /// </summary>
        /// <param name="searchModel">Product search model to add to the category</param>
        /// <returns>Product list model to add to the category</returns>
        public virtual AddQuestionToCategoryListModel PrepareAddQuestionToCategoryListModel(AddQuestionToCategorySearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get products
            var products = _questionService.GetAllQuestions(categoryIds: new List <int> {
                searchModel.SearchCategoryId
            },
                                                            questionType: searchModel.SearchQuestionTypeId > 0 ? (QuestionType?)searchModel.SearchQuestionTypeId : null,
                                                            pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize);

            //prepare grid model
            var model = new AddQuestionToCategoryListModel().PrepareToGrid(searchModel, products, () =>
            {
                return(products.Select(product =>
                {
                    var productModel = product.ToModel <QuestionModel>();
                    return productModel;
                }));
            });

            return(model);
        }
コード例 #2
0
        /// <summary>
        /// Prepare product search model to add to the category
        /// </summary>
        /// <param name="searchModel">Product search model to add to the category</param>
        /// <returns>Product search model to add to the category</returns>
        public virtual AddQuestionToCategorySearchModel PrepareAddQuestionToCategorySearchModel(AddQuestionToCategorySearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //prepare available categories
            _baseAdminModelFactory.PrepareCategories(searchModel.AvailableCategories);

            //prepare available product types
            _baseAdminModelFactory.PrepareQuestionTypes(searchModel.AvailableQuestionTypes);

            //prepare page parameters
            searchModel.SetPopupGridPageSize();

            return(searchModel);
        }