Exemple #1
0
        public IActionResult Index(
            int grammarPage         = 1,
            string grammarSearchKey = "",
            string lookup           = "")
        {
            #region For grammar
            int topicStart = (grammarPage - 1) * Math.Min(10, Config.PAGE_PAGINATION_LIMIT);

            var grammars = _TestCategoryManager.GetByPagination(TestCategory.READING, 1, topicStart, Math.Min(10, Config.PAGE_PAGINATION_LIMIT), grammarSearchKey);
            ViewBag.Grammars         = grammars;
            ViewBag.GrammarSearchKey = grammarSearchKey;

            // Tạo đối tượng phân trang cho Grammars
            ViewBag.GrammarPagination = new Pagination(nameof(Index), NameUtils.ControllerName <DictionaryController>())
            {
                PageKey     = nameof(grammarPage),
                PageCurrent = grammarPage,
                NumberPage  = PaginationUtils.TotalPageCount(
                    _TestCategoryManager.CountFor(TestCategory.READING, 1, grammarSearchKey),
                    Math.Min(10, Config.PAGE_PAGINATION_LIMIT)),
                Offset = Math.Min(10, Config.PAGE_PAGINATION_LIMIT)
            };
            #endregion

            #region For search vocabulary
            ViewBag.Vocabularies = _VocabularyManager.LookUp(lookup ?? string.Empty);
            ViewBag.LookUp       = lookup;
            #endregion
            return(View());
        }
Exemple #2
0
        private IEnumerable <TestCategory> CategoryRender(string actionName, string typeCode, int partId, int categoryPage = 1, string categorySearchKey = "")
        {
            int categoryStart = (categoryPage - 1) * Config.PAGE_PAGINATION_LIMIT;

            var testCategories = _TestCategoryManager.GetByPagination(typeCode, partId, categoryStart, Config.PAGE_PAGINATION_LIMIT);

            // Tạo đối tượng phân trang cho Category
            ViewBag.CategoryPagination = new Pagination(actionName, NameUtils.ControllerName <SpeakingManagerController>())
            {
                PageKey     = nameof(categoryPage),
                PageCurrent = categoryPage,
                NumberPage  = PaginationUtils.TotalPageCount(
                    _TestCategoryManager.GetAll(typeCode, partId).Count(),
                    Config.PAGE_PAGINATION_LIMIT),
                Offset = Config.PAGE_PAGINATION_LIMIT
            };
            return(testCategories);
        }