Пример #1
0
        public IActionResult Index(
            long topic                 = -1,
            int topicPage              = 1,
            int vocabularyPage         = 1,
            string topicSearchKey      = "",
            string vocabularySearchKey = "")
        {
            #region For topic
            int topicStart = (topicPage - 1) * Config.PAGE_PAGINATION_LIMIT;

            var topics = _TopicManager.GetByPagination(topicStart, Config.PAGE_PAGINATION_LIMIT);
            ViewBag.Topics = topics;

            // Tạo đối tượng phân trang cho Category
            ViewBag.TopicPagination = new Pagination(nameof(Index), NameUtils.ControllerName <DictionaryManagerController>())
            {
                PageKey     = nameof(topicPage),
                PageCurrent = topicPage,
                NumberPage  = PaginationUtils.TotalPageCount(
                    _TopicManager.Count().ToInt(),
                    Config.PAGE_PAGINATION_LIMIT),
                Offset = Config.PAGE_PAGINATION_LIMIT
            };
            #endregion

            #region For vocabulary
            int vocabularyStart = (vocabularyPage - 1) * Config.PAGE_PAGINATION_LIMIT;

            int total = _VocabularyManager.CountFor(topic).ToInt();

            // Tạo đối tượng phân trang cho Câu hỏi
            ViewBag.VocabularyPagination = new Pagination(nameof(Index), NameUtils.ControllerName <ReadingManagerController>())
            {
                PageKey     = nameof(vocabularyPage),
                PageCurrent = vocabularyPage,
                TypeKey     = nameof(topic),
                Type        = "0",
                NumberPage  = PaginationUtils.TotalPageCount(total, Config.PAGE_PAGINATION_LIMIT),
                Offset      = Config.PAGE_PAGINATION_LIMIT
            };

            ViewBag.TopicName = _TopicManager.Get(topic)?.Name ?? "";

            if (topic <= 0)
            {
                ViewBag.TopicName = "ALL";
            }

            ViewBag.Vocabularies = _VocabularyManager.GetByPagination(topic, vocabularyStart, Config.PAGE_PAGINATION_LIMIT);
            #endregion

            return(View());
        }