// // GET: /Tags/ public ActionResult Index(int? page) { Int32 currentPage = page ?? 1; IQueryable<XsTag> tags = tagRepository.GetTagsByQuestionTotal().AsQueryable(); IPagination pageTags = tags.AsPagination(currentPage, Settings.TAGS_PAGINATION_SIZE); Int32 currentPageSize = Settings.TAGS_PAGINATION_SIZE; if (currentPage == pageTags.TotalPages) { currentPageSize = pageTags.TotalItems - (pageTags.TotalPages - 1) * Settings.TAGS_PAGINATION_SIZE; } else { if (0 == pageTags.TotalPages) { currentPageSize = 0; } } TagsIndexViewModel viewModel = new TagsIndexViewModel() { CurrentPageSize = currentPageSize, Tags = pageTags }; return View(viewModel); }
// // GET: /Questions/ public ActionResult Index(int? page) { Int32 currentPage = page ?? 1; IQueryable<XsQuestion> questions = from question in questionRepository.GetAll() orderby question.UpdateDT descending select question; IPagination pageQuestions = questions.AsPagination(currentPage, Settings.QUESTIONS_PAGINATION_SIZE); Int32 currentPageSize = Settings.QUESTIONS_PAGINATION_SIZE; if (currentPage == pageQuestions.TotalPages) { currentPageSize = pageQuestions.TotalItems - (pageQuestions.TotalPages - 1) * Settings.QUESTIONS_PAGINATION_SIZE; } else { if (0 == pageQuestions.TotalPages) { currentPageSize = 0; } } TagsIndexViewModel viewModel = new TagsIndexViewModel() { CurrentPageSize = currentPageSize, Tags = pageQuestions }; IList<XsTag> popularTags = tagRepository.GetTagsByQuestionTotal().Take(Settings.POPULAR_TAGS_LIMIT).ToList(); QuestionsIndexViewModel questionsViewModel = new QuestionsIndexViewModel() { Questions = pageQuestions, PopularTags = popularTags, CurrentPageSize = currentPageSize }; return View(questionsViewModel); }