public async Task <SearchResponse <PackageIndexViewModel> > SearchAsync(SearchRequest <PackageIndexViewModel> request) { SearchResponse <PackageIndexViewModel> response = null; if (request is null) { return(response.CreateFailedResponse(ErrorTypes.BadRequest, "Bad Request")); } List <Expression <Func <Package, bool> > > filters = GetPackageSearchFilters(request); // (IEnumerable<Package> items, int totalCount) = await UnitOfWork.PackageRepository.GetPagedByFiltersAsync(request.PageIndex, request.PageSize, filters, o => o.OrderByDescending(p => p.Id)); (IEnumerable <Package> items, int totalCount) = UnitOfWork.PackageRepository.GetAll() .Where(filters) .OrderByDescending(p => p.Id) .ToPagesList(request.PageIndex, request.PageSize); response = new SearchResponse <PackageIndexViewModel> { Data = request.Data ?? new PackageIndexViewModel(), TotalItemsCount = totalCount, PageIndex = request.PageIndex, Success = true, Message = "ok" }; response.Data.Results = items.ToList(); return(response); }