Example #1
0
        public async Task OnGetAsync(SortState?sortOrder, int?pageIndex)
        {
            CurrentSort = sortOrder;                                 //сохранение состояния сортировки
            IQueryable <Requests> RequestsIQ = _db.GetAllRequests(); //формируем запрос к БД

            ViewData["NameSort"]    = sortOrder == SortState.NameAsc ? SortState.NameDesc : SortState.NameAsc;
            ViewData["PhoneSort"]   = sortOrder == SortState.PhoneAsc ? SortState.PhoneDesc : SortState.PhoneAsc;
            ViewData["EmailSort"]   = sortOrder == SortState.EmailAsc ? SortState.EmailDesc : SortState.EmailAsc;
            ViewData["MessageSort"] = sortOrder == SortState.MessageAsc ? SortState.MessageDesc : SortState.MessageAsc;
            ViewData["DateSort"]    = sortOrder == SortState.DateAsc ? SortState.DateDesc : SortState.DateAsc;

            RequestsIQ = _db.Sorting(RequestsIQ, sortOrder); //сортировка

            int pageSize = 10;                               //количество элементов на странице

            Requests = await PaginatedList <Requests> .CreateAsync(
                RequestsIQ.AsNoTracking(), pageIndex ?? 1, pageSize); //вызываем метод пагинации
        }