示例#1
0
        public IActionResult GetDetectionErrors([FromQuery] DetectionErrorQueryFilter filters)
        {
            //var request = _httpContextAccessor.HttpContext.Request;
            //string str = request.QueryString.ToString();
            //string stringBeforeChar = str.Substring(0, str.IndexOf("&"));
            var detectionErrors    = _detectionErrorService.GetDetectionErrors(filters);
            var detectionErrorsDto = _mapper.Map <IEnumerable <DetectionErrorDto> >(detectionErrors);
            //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      = detectionErrors.TotalCount,
                PageSize        = detectionErrors.PageSize,
                CurrentPage     = detectionErrors.CurrentPage,
                TotalPages      = detectionErrors.TotalPages,
                HasNextPage     = detectionErrors.HasNextPage,
                HasPreviousPage = detectionErrors.HasPreviousPage,
            };

            var response = new ApiResponse <IEnumerable <DetectionErrorDto> >(detectionErrorsDto)
            {
                Meta = metadata
            };

            Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(metadata));

            return(Ok(response));
        }
示例#2
0
        public PagedList <DetectionError> GetDetectionErrors(DetectionErrorQueryFilter filters)
        {
            filters.PageNumber = filters.PageNumber == 0 ? _paginationOptions.DefaultPageNumber : filters.PageNumber;
            filters.PageSize   = filters.PageSize == 0 ? _paginationOptions.DefaultPageSize : filters.PageSize;
            var detectionErrors = _unitOfWork.DetectionErrorRepository.GetAll();

            var pagedDetectionErrors = PagedList <DetectionError> .Create(detectionErrors, filters.PageNumber, filters.PageSize);

            return(pagedDetectionErrors);
        }
示例#3
0
        public Uri GetDetectionErrorPaginationUri(DetectionErrorQueryFilter filter, string actionUrl)
        {
            string baseUrl = $"{_baseUri}{actionUrl}";

            return(new Uri(baseUrl));
        }