示例#1
0
        public ActionResult Index(int?page)
        {
            long?userId = null;

            if (User.Identity.IsAuthenticated)
            {
                userId = User.Identity.GetUserId <long>();
            }
            var model = _problemsService.GetProblemsList(page ?? 1, _pageSize, userId, false);

            return(View(model));
        }
示例#2
0
        public void FirstPageTest()
        {
            const int pageSize = 100;
            const int page     = 1;

            var tasks = new[] { new TaskName {
                                    Id = 1, Name = "A"
                                }, new TaskName {
                                    Id = 2, Name = "B"
                                } };

            _taskRepository.Stub(o => o.GetTasks(OpenedTasksSpecification.Instance, page, pageSize)).Return(tasks);
            _taskRepository.Stub(o => o.Count(true)).Return(tasks.Length);

            var model = _service.GetProblemsList(page, pageSize, null, true);

            Assert.That(model.ProblemsCount, Is.EqualTo(2));
            Assert.That(model.Pagination.PageSize, Is.EqualTo(pageSize));
            Assert.That(model.Pagination.CurrentPage, Is.EqualTo(page));
            Assert.That(model.Pagination.TotalPages, Is.EqualTo(1));

            CollectionAssert.AreEqual(tasks.Select(o => new { o.Id, o.Name }), model.Problems.Select(o => new { o.Id, o.Name }));
        }
示例#3
0
        public ActionResult Problems(int?page)
        {
            var model = _problemsService.GetProblemsList(page ?? 1, 20, null, false);

            return(View(model));
        }