예제 #1
0
        public async Task <PagedList <BuildingCategory> > GetBuildingTypesPagination(PagUserParams userParams)
        {
            var buildingTypes = await _buildingsRepo.GetBuildingTypesPagination(
                userParams
                );

            return(buildingTypes);
        }
예제 #2
0
        public async Task <IActionResult> GetBuildingTypesPagination([FromQuery] PagUserParams userParams)
        {
            var buildingTypes = await _buildingService.GetBuildingTypesPagination(userParams);

            var bldgTypesToReturn = _mapper.Map <IEnumerable <BuildingTypeDataDto> >(buildingTypes);

            Response.AddPagination(buildingTypes.CurrentPage,
                                   buildingTypes.PageSize,
                                   buildingTypes.TotalCount,
                                   buildingTypes.TotalPages);

            return(Ok(bldgTypesToReturn));
        }
예제 #3
0
        public async Task <PagedList <BuildingCategory> > GetBuildingTypesPagination(
            PagUserParams userParams,
            Expression <Func <BuildingCategory, object> >[] includeProperties = null,
            Expression <Func <BuildingCategory, bool> > filter = null
            )
        {
            var buildingCategories = _context.BuildingCategories.AsQueryable();

            if (includeProperties != null)
            {
                foreach (Expression <Func <BuildingCategory, object> > includeProperty in includeProperties)
                {
                    buildingCategories = buildingCategories.Include <BuildingCategory, object>(includeProperty);
                }
            }

            if (filter != null)
            {
                buildingCategories = buildingCategories.Where(filter);
            }

            return(await PagedList <BuildingCategory> .CreateAsync(buildingCategories, userParams.PageNumber, userParams.PageSize));
        }