예제 #1
0
        public ActionResult DisplayPage(Pager pager)
        {
            if (pager == null || !this.ModelState.IsValid)
            {
                return(this.HttpNotFound("The specified page has disappeared without a trace"));
            }

            if (pager.TotalPages == 0)
            {
                pager.TotalPages = this.quizzes.GetTotalPages(pager.CategoryName, QuizzesPerPage);
            }

            var rankingPeriod = new WeeklyRange();
            var maxSolutions  = this.GetMaxSolutions(rankingPeriod);

            var models = this.Ranking.GetQuizzesOrderedBySolutions(rankingPeriod)
                         .Where(q => q.Category.Name == pager.CategoryName)
                         .ApplyPaging(pager)
                         .To <QuizRankedBySolutions>()
                         .ToArray();

            var viewModel = new HomePageViewModel(maxSolutions, rankingPeriod, pager)
            {
                Quizzes    = models,
                Categories = this.GetTopCategories(),
            };

            return(this.View(viewModel));
        }
예제 #2
0
        public ActionResult DisplayPage(Pager pager)
        {
            if (pager == null || !this.ModelState.IsValid)
            {
                return this.HttpNotFound("The specified page has disappeared without a trace");
            }

            if (pager.TotalPages == 0)
            {
                pager.TotalPages = this.quizzes.GetTotalPages(pager.CategoryName, QuizzesPerPage);
            }

            var rankingPeriod = new WeeklyRange();
            var maxSolutions = this.GetMaxSolutions(rankingPeriod);

            var models = this.Ranking.GetQuizzesOrderedBySolutions(rankingPeriod)
                .Where(q => q.Category.Name == pager.CategoryName)
                .ApplyPaging(pager)
                .To<QuizRankedBySolutions>()
                .ToArray();

            var viewModel = new HomePageViewModel(maxSolutions, rankingPeriod, pager)
            {
                Quizzes = models,
                Categories = this.GetTopCategories(),
            };

            return this.View(viewModel);
        }