Пример #1
0
        public async Task <IActionResult> Index(string sortOrder, string currentFilter, string searchString, int?pageNumber)
        {
            ViewData["CurrentSort"]   = sortOrder;
            ViewData["AbrvSort"]      = sortOrder == Strings.AbrvAsc ? Strings.AbrvDesc : Strings.AbrvAsc;
            ViewData["NameSort"]      = sortOrder == Strings.NameDesc ? Strings.NameAsc : Strings.NameDesc;
            ViewData["CurrentFilter"] = searchString;

            if (searchString != null)
            {
                pageNumber = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewData["CurrentFilter"] = searchString;
            Searching searching = new Searching();
            Sorting   sorting   = new Sorting();
            PaginatedList <IVehicleMake> paging = new PaginatedList <IVehicleMake>();

            searching.SearchingString = searchString;
            sorting.SortOrder         = sortOrder;
            paging.PageNumber         = pageNumber ?? 1;

            List <IVehicleMake> vehicles = await service.GetAllMakes(searching, sorting, paging);

            List <VehicleMakeView>          items            = mapper.Map <List <VehicleMakeView> >(vehicles);
            PaginatedList <VehicleMakeView> getPaginatedList = new PaginatedList <VehicleMakeView>(items, paging.PageCount, paging.PageNumber, Strings.PageSize);

            return(View(getPaginatedList));
        }