public IActionResult Get([FromQuery] PlantQueryParameters queryParams) { queryParams.Take = (queryParams.Take < 1 || queryParams.Take > 200) ? 50 : queryParams.Take; queryParams.PageIndex = (queryParams.PageIndex < 0) ? 0 : queryParams.PageIndex; List <UserPlant> plantList = _plantData.Get(queryParams); if (plantList == null) { return(NotFound()); } IEnumerable <UserPlantDisplayViewModel> models = plantList.Select(p => new UserPlantDisplayViewModel(p)); PaginationModel nextPreviousQuary = new PaginationModel { Next = GetNextPreviousURL(queryParams, 1), Previous = GetNextPreviousURL(queryParams, -1) }; Response.Headers.Add( "x-Pagination", JsonConvert.SerializeObject(nextPreviousQuary) ); return(Ok(models)); }
public IActionResult Get([FromQuery] PlantTypeQueryParameters queryParams) { queryParams.Take = (queryParams.Take < 1 || queryParams.Take > 200) ? 50 : queryParams.Take; queryParams.PageIndex = (queryParams.PageIndex < 0) ? 0 : queryParams.PageIndex; List <PlantType> plantList = _plantData.Get(queryParams); if (plantList == null) { return(NotFound()); } IEnumerable <PlantTypeDisplayViewModel> models = plantList.Select(p => new PlantTypeDisplayViewModel(p)); return(Ok(models)); }