public async Task <IActionResult> GetPaginatedWithFilter([FromQuery] SegmentFilterPaginatedRequest request) { var response = await _segmentService.GetPaginatedWithFilter(request); return(Ok(response)); }
public async Task <PaginatedResponse <SegmentResponse> > GetPaginatedWithFilter(SegmentFilterPaginatedRequest request) { IEnumerable <Segment> result = await _segmentRepository.GetPaginatedWithFilterAsync(request.Description, request.Page, request.PageSize); int totalRegisters = await _segmentRepository.Count(request.Description); PaginatedResponse <SegmentResponse> response = new PaginatedResponse <SegmentResponse> { Data = result?.Select(x => (SegmentResponse)x)?.ToList(), TotalItems = totalRegisters, TotalPages = (long)Math.Ceiling((double)totalRegisters / (double)request.PageSize) }; return(response); }