Пример #1
0
        public ActionResult List(int?page)
        {
            page = page.HasValue ? page.Value : 1;
            var viewModel        = new AbsolutionsViewModel();
            int totalIndulgences = _indulgeMeService.IndulgencesCount();

            viewModel.Indulgences          = _indulgeMeService.AllIndulgences(page.Value - 1, pageSize);
            viewModel.SiteInfo             = _indulgeMeService.GetSiteSummaryInfo();
            viewModel.Page                 = page.Value;
            viewModel.NextPage             = page.Value + 1;
            viewModel.PreviousPage         = page.Value > 1 ? page.Value - 1 : 0;
            viewModel.CurrentPage          = page.Value;
            viewModel.ShowNextPageLink     = (totalIndulgences / pageSize) + 1 > page.Value;
            viewModel.ShowPreviousPageLink = page.Value > 1;

            viewModel.PagingStart = viewModel.CurrentPage - 5 > 1 ? viewModel.CurrentPage - 5 : 1;
            viewModel.PagingEnd   = viewModel.CurrentPage + 5 < (totalIndulgences / pageSize) + 1 ? viewModel.CurrentPage + 5 : (totalIndulgences / pageSize) + 1;

            return(View(viewModel));
        }