コード例 #1
0
        protected void PopulateIndexModel(CategoryIndexModel model)
        {
            model.CategoryType = CategoryType;

            model.InitSortInfo();

            if (string.IsNullOrWhiteSpace(model.SortBy))
            {
                model.SortBy = CategoryType == CategoryType.Product ? "Code" : "Name";
            }

            var filter = new FindRequest
            {
                TextSearch = model.TextSearch,
                CategoryType = CategoryType,
                SortOption = new SortOption(new[] { new SortItem(model.SortBy, model.SortDirection.Value) })
            };

            var response = ServiceHelper.Category.ExecuteDispose(s => s.FindCategories(filter));

            var listTree = SiteUtils.BuildCategoryTreeFromList(response.Results);

            model.Results = listTree.MapList<CategoryModel>();

            model.Pagination.TotalRecords = response.TotalRecords;
        }