public async Task <IActionResult> GetVisitTypes([FromQuery] VisitTypeParametersDto visitTypeParametersDto)
        {
            var visitTypessFromRepo = await _visitTypeRepository.GetVisitTypesAsync(visitTypeParametersDto);

            var paginationMetadata = new
            {
                totalCount        = visitTypessFromRepo.MetaData.TotalCount,
                pageSize          = visitTypessFromRepo.MetaData.PageSize,
                currentPageSize   = visitTypessFromRepo.MetaData.CurrentPageSize,
                currentStartIndex = visitTypessFromRepo.MetaData.CurrentStartIndex,
                currentEndIndex   = visitTypessFromRepo.MetaData.CurrentEndIndex,
                pageNumber        = visitTypessFromRepo.MetaData.PageNumber,
                totalPages        = visitTypessFromRepo.MetaData.TotalPages,
                hasPrevious       = visitTypessFromRepo.MetaData.HasPrevious,
                hasNext           = visitTypessFromRepo.MetaData.HasNext
            };

            Response.Headers.Add("X-Pagination",
                                 JsonSerializer.Serialize(paginationMetadata));

            var visitTypessDto = _mapper.Map <IEnumerable <VisitTypeDto> >(visitTypessFromRepo);
            var response       = new Response <IEnumerable <VisitTypeDto> >(visitTypessDto);

            return(Ok(response));
        }
Exemple #2
0
        public async Task <IActionResult> Index(int page = 1, int pageSize = 10, String filters = "", String sortOrder = "")
        {
            ViewBag.pageSize = pageSize;
            ViewBag.filter   = filters;

            ViewData["IdSortParm"]   = sortOrder == "Id" ? "-Id" : "Id";
            ViewData["NameSortParm"] = sortOrder == "Name" ? "-Name" : "Name";

            VisitTypeParametersDto visitTypeParameters = new VisitTypeParametersDto()
            {
                PageNumber = page,
                PageSize   = pageSize,
                SortOrder  = sortOrder,
                Filters    = filters
            };

            var pagingResponse = await _visitTypeRepo.GetVisitTypesAsync(visitTypeParameters);

            return(View(pagingResponse));
        }