Example #1
0
        public IActionResult GetList(AiBookSearchModelView searchModel)
        {
            //prepare model
            var model = _bookNodeFactory.PrepareBookNodeListModel(searchModel);

            return(Json(model));
        }
Example #2
0
        public AiBookModelListView PrepareBookNodeListModel(AiBookSearchModelView searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }



            var result = _aiBookService.SearchAiBookModels(searchModel.BookAiModelName, searchModel.Page - 1, searchModel.PageSize, new List <int> {
                searchModel.CateId
            }, searchModel.BookId, searchModel.BookDirId, 0);

            var model = new AiBookModelListView().PrepareToGrid(searchModel, result, () =>
            {
                return(result.Select(category =>
                {
                    //fill in model values from the entity
                    var categoryModel = category.ToModel <AiBookModelView>();
                    //fill in additional values (not existing in the entity)
                    //categoryModel.Breadcrumb = _bookDirService.GetFormattedBreadCrumb(category);
                    //categoryModel.SeName = _urlRecordService.GetSeName(category, 0, true, false);
                    return categoryModel;
                }));
            });


            return(model);
            // _baseAdminModelFactory.PrepareCategories(searchModel.AvailableCategories,
            // defaultItemText: _localizationService.GetResource("Admin.Catalog.Categories.Fields.Parent.None"));


            //if (searchModel.BookId > 0)
            //{
            //    var result = _productService.GetProductById(searchModel.BookId);
            //    if (result != null)
            //    {
            //        if (result.ProductCategories != null)
            //        {
            //            searchModel.CateId = result.ProductCategories.FirstOrDefault().CategoryId;
            //        }
            //        searchModel.BookId = result.Id;
            //        searchModel.AvailableBooks = SelectListHelper.GetBookList(_productService, new List<int> { searchModel.CateId });
            //    }
            //}
            //if (searchModel.BookDirId > 0)
            //{
            //    searchModel.AvailableBookDirs = SelectListHelper.GetBookDirList(_bookdirService);
            //}
            //return searchModel;
            // throw new NotImplementedException();
        }
Example #3
0
        public IActionResult Index(AiBookSearchModelView smodel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManagerBook))
            {
                return(AccessDeniedView());
            }

            //prepare model
            //  var model = _bookDirFactory.PrepareBookDirSearchModel(new BookDirSearchModel(),new BookDirModel());
            var model = _bookNodeFactory.PrepareBookNodeSearchModel(smodel);

            return(View(model));
        }
Example #4
0
        public virtual IActionResult List(AiBookSearchModelView searchModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories))
            {
                return(AccessDeniedDataTablesJson());
            }

            //prepare model
            // var model = _bookDirFactory.PrepareBookDirSearchModel(searchModel,new BookDirModel());
            var model = _bookNodeFactory.PrepareBookNodeSearchModel(searchModel);

            return(Json(model));
        }
Example #5
0
        //public virtual IActionResult Index()
        //{
        //    return RedirectToAction("List");
        //}

        public virtual IActionResult List()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.BookModelManage))
            {
                return(AccessDeniedView());
            }


            var smodel = new AiBookSearchModelView();


            //prepare model
            //  var model = _bookDirFactory.PrepareBookDirSearchModel(new BookDirSearchModel(),new BookDirModel());
            var model = _bookNodeFactory.PrepareBookNodeSearchModel(smodel);

            return(View(model));
        }
Example #6
0
        public AiBookSearchModelView PrepareBookNodeSearchModel(AiBookSearchModelView searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }


            _baseAdminModelFactory.PrepareCategories(searchModel.AvailableCategories,
                                                     defaultItemText: _localizationService.GetResource("Admin.Catalog.Categories.Fields.Parent.None"));
            if (searchModel.BookDirId > 0)
            {
                var bookdir = _bookdirService.GetBookDirById(searchModel.BookDirId);

                if (bookdir != null)
                {
                    searchModel.BookId = bookdir.BookID;
                }
                searchModel.AvailableBookDirs = SelectListHelper.GetBookDirList(_bookdirService);
            }

            if (searchModel.BookId > 0)
            {
                var result = _productService.GetProductById(searchModel.BookId);
                if (result != null)
                {
                    if (result.ProductCategories != null)
                    {
                        searchModel.CateId = result.ProductCategories.FirstOrDefault().CategoryId;
                    }
                    searchModel.BookId         = result.Id;
                    searchModel.AvailableBooks = SelectListHelper.GetBookList(_productService, new List <int> {
                        searchModel.CateId
                    });
                }
            }

            return(searchModel);
        }