public async Task <IActionResult> GetAll([FromQuery] TerceroQueryFilter filters) { var terceros = await _service.GetAll(filters); var tercerosDto = _mapper.Map <IEnumerable <TerceroDto> >(terceros); var respose = new ApiResponse <IEnumerable <TerceroDto> >(tercerosDto); var matadata = new { terceros.TotalCount, terceros.PageSize, terceros.CurrentPage, terceros.TotlaPages, terceros.HasNextPage, terceros.HasPreviousPage }; Response.Headers.Add("X-Pagination", JsonSerializer.Serialize(matadata)); return(Ok(respose)); }
public async Task <PageList <Tercero> > GetAll(TerceroQueryFilter filters) { var terceros = await _unitOfWork.TerceroRepository.GetAll(); if (filters.Identificaion != null) { terceros = terceros.Where(x => x.Identificaion.ToLower().Contains(filters.Identificaion.ToLower())); } if (filters.Nombres != null) { terceros = terceros.Where(x => x.Nombres.ToLower().Contains(filters.Nombres.ToLower())); } if (filters.Apellidos != null) { terceros = terceros.Where(x => x.Apellidos != null && x.Apellidos.ToLower().Contains(filters.Apellidos.ToLower())); } if (filters.Correo != null) { terceros = terceros.Where(x => x.Correo != null && x.Correo.ToLower().Contains(filters.Correo.ToLower())); } if (filters.Direccion != null) { terceros = terceros.Where(x => x.Direccion != null && x.Direccion.ToLower().Contains(filters.Direccion.ToLower())); } if (filters.Telefono != null) { terceros = terceros.Where(x => x.Telefono != null && x.Telefono.ToLower().Contains(filters.Telefono.ToLower())); } var pageTerceros = PageList <Tercero> .Create(terceros, filters.PageNumber, filters.PageSize); return(pageTerceros); }