Ejemplo n.º 1
0
        public async Task <IActionResult> GetAll([FromQuery] PoolFilter filter, [FromQuery] int rowsPerPage = 20, [FromQuery] int pageNumber = 1)
        {
            string userEmail = User.FindFirst(ClaimTypes.Email).Value;
            User   user      = await userManager.FindByEmailAsync(userEmail);

            PaginatedElement <Pool> pools = poolService.Get(filter, rowsPerPage, pageNumber, user);

            PaginatedDto <PoolDto> dto = mapper.Map <PaginatedDto <PoolDto> >(pools);

            dto.NextPageUrl = HttpContext.GetNextPageUrl(pageNumber < dto.PageCount);

            return(Ok(dto));
        }
Ejemplo n.º 2
0
        public Pool Get(int poolId, User user = null)
        {
            IFilter <Pool> filter = new PoolFilter();

            if (user != null)
            {
                filter = new IdentityPoolFilter(filter, user);
            }

            Pool pool = poolRepository.GetById(poolId, filter);

            if (pool == null)
            {
                throw new NotFoundException(typeof(Pool));
            }

            return(pool);
        }