public async Task <IActionResult> GetPointsRelais([FromQuery] PointRelaisParameters parameters) { var pointsRelais = await _ponitRelaisRepository.GetPointsRelaisAsync(parameters); var pointsRelaisDto = _mapper.Map <IEnumerable <PointRelaisDto> >(pointsRelais); Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(pointsRelais.GetMetadata())); return(Ok(pointsRelaisDto)); }
public async Task <PagedList <PointRelais> > GetPointsRelaisAsync(PointRelaisParameters parameters) { var pointsRelais = _context.PointsRelais as IQueryable <PointRelais>; if (!string.IsNullOrWhiteSpace(parameters.IdPointRelais)) { pointsRelais = pointsRelais.Where(p => p.IdPointRelais == parameters.IdPointRelais); } pointsRelais = !string.IsNullOrWhiteSpace(parameters.OrderBy) ? pointsRelais.ApplySort(parameters.OrderBy) : pointsRelais.OrderBy(p => p.LibelleCommercial); return(PagedList <PointRelais> .ToPagedList(await pointsRelais.ToListAsync(), parameters.PageNumber, parameters.PageSize)); }