Exemple #1
0
        public async Task <ActionResult <PaginatedItemsViewModel <PurchaseOrderDetailDTO> > > GetListAsync(
            [FromQuery] int pageSize  = 10,
            [FromQuery] int pageIndex = 0,
            [FromQuery] Dictionary <string, Dictionary <string, List <string> > > filter = default,
            [FromQuery] Dictionary <string, int> sorting = default,
            [FromQuery] Dictionary <string, int> exact   = default,
            CancellationToken cancellation = default)
        {
            InitUserInfo();
            if (!AllowRead)
            {
                return(ValidationProblem());
            }
            CleanFilter(filter);
            var filterSpec = GenerateFilter(filter, exact);
            var totalItems = await _purchaseOrderDetailService.CountAsync(filterSpec, cancellation);

            var sortingSpec     = GenerateSortingSpec(sorting);
            var pagedFilterSpec = GenerateFilter(filter, exact, pageSize, pageIndex, sortingSpec);
            var items           = await _purchaseOrderDetailService.ListAsync(pagedFilterSpec, sortingSpec, false, cancellation);

            var model = new PaginatedItemsViewModel <PurchaseOrderDetailDTO>(pageIndex, pageSize, totalItems, items.Select(_mapper.Map <PurchaseOrderDetailDTO>));

            return(Ok(model));
        }