public IActionResult GetDetections([FromQuery] DetectionQueryFilter filters) { //var request = _httpContextAccessor.HttpContext.Request; //string str = request.QueryString.ToString(); //string stringBeforeChar = str.Substring(0, str.IndexOf("&")); var detections = _detectionService.GetDetections(filters); var detectionsDto = _mapper.Map <IEnumerable <DetectionDto> >(detections); //var nextPage = bookGroups.CurrentPage >= 1 && bookGroups.CurrentPage < bookGroups.TotalCount // ? _uriService.GetPageUri(bookGroups.CurrentPage + 1, bookGroups.PageSize, _uriService.GetBookGroupPaginationUri(filters, Url.RouteUrl(nameof(GetBookGroups))).ToString() + stringBeforeChar) // : null; //var previousPage = bookGroups.CurrentPage - 1 >= 1 && bookGroups.CurrentPage < bookGroups.TotalCount // ? _uriService.GetPageUri(bookGroups.CurrentPage - 1, bookGroups.PageSize, _uriService.GetBookGroupPaginationUri(filters, Url.RouteUrl(nameof(GetBookGroups))).ToString() + stringBeforeChar) // : null; var metadata = new Metadata { TotalCount = detections.TotalCount, PageSize = detections.PageSize, CurrentPage = detections.CurrentPage, TotalPages = detections.TotalPages, HasNextPage = detections.HasNextPage, HasPreviousPage = detections.HasPreviousPage, }; var response = new ApiResponse <IEnumerable <DetectionDto> >(detectionsDto) { Meta = metadata }; Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(metadata)); return(Ok(response)); }
public PagedList <Detection> GetDetections(DetectionQueryFilter filters) { filters.PageNumber = filters.PageNumber == 0 ? _paginationOptions.DefaultPageNumber : filters.PageNumber; filters.PageSize = filters.PageSize == 0 ? _paginationOptions.DefaultPageSize : filters.PageSize; var detections = _unitOfWork.DetectionRepository.GetAll(); var pagedDetections = PagedList <Detection> .Create(detections, filters.PageNumber, filters.PageSize); return(pagedDetections); }
public Uri GetDetectionPaginationUri(DetectionQueryFilter filter, string actionUrl) { string baseUrl = $"{_baseUri}{actionUrl}"; return(new Uri(baseUrl)); }