public async Task <IActionResult> Activos([FromQuery] int pageSize = 6, [FromQuery] int pageIndex = 0) { var totalactivos = await _catalogcontext.CatalogActivos .LongCountAsync(); var activosOnPage = await _catalogcontext.CatalogActivos .OrderBy(c => c.Detalle) .Skip(pageSize = pageIndex) .Take(pageSize) .ToListAsync(); var model = new PaginateItemsViewModel <CatalogActivos>(pageIndex, pageSize, totalactivos, activosOnPage); return(Ok(model)); }
public async Task <IActionResult> Activos(int?tipoactivoId, [FromQuery] int pageSize = 6, [FromQuery] int pageIndex = 0) { var root = (IQueryable <CatalogActivos>)_catalogcontext.CatalogActivos; if (tipoactivoId.HasValue) { root = root.Where(c => c.TipoActivosID == tipoactivoId); } var totalactivos = await root .LongCountAsync(); var activosOnPage = await root .OrderBy(c => c.Detalle) .Skip(pageSize = pageIndex) .Take(pageSize) .ToListAsync(); var model = new PaginateItemsViewModel <CatalogActivos>(pageIndex, pageSize, totalactivos, activosOnPage); return(Ok(model)); }