public async Task <IEnumerable <CatalogType> > GetCatalogTypesAsync(CatalogResourceParameters ctgResourcePrms) { var collection = await _dbContext.CatalogTypes .Include(x => x.CatalogItems).ToListAsync(); return(collection); }
public async Task <IActionResult> GetCatalogTypes(CatalogResourceParameters ctgResourcePrms) { var catalogs = await _catalogSvc.GetCatalogTypesAsync(ctgResourcePrms); if (catalogs is null) { _logger.LogInformation(Resource.NotFound); return(NotFound(ResponseError.Create(Resource.NotFound))); } var pagedList = catalogs.ToPagedList(ctgResourcePrms); var previousPageLink = pagedList.HasPrevious ? _linkHelper.GenerateLink(RESTAPI.Route.GET_GATALOGS, ctgResourcePrms, ResourceUriType.PreviousPage) : null; var nextPageLink = pagedList.HasNext ? _linkHelper.GenerateLink(RESTAPI.Route.GET_GATALOGS, ctgResourcePrms, ResourceUriType.NextPage) : null; var paginationMetadata = new { totalCount = pagedList.TotalCount, pageSize = pagedList.Pagesize, currentPage = pagedList.CurrentPage, totalPages = pagedList.TotalPages, previousPageLink, nextPageLink }; Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(paginationMetadata)); var responseObj = pagedList.ToViewModelList <CatalogType, CatalogTypeDto>(); return(Ok(ResponseSuccess.Create(responseObj))); }
Task <IEnumerable <CatalogType> > ICatalogService.GetCatalogTypesAsync(CatalogResourceParameters ctgResourcePrms) { throw new NotImplementedException(); }
public IEnumerable <CatalogType> GetCatalogTypesAsync(CatalogResourceParameters ctgResourcePrms) { return(FakeData.FakeData.GetCatalogType()); }
public async Task <IEnumerable <CatalogType> > GetCatalogTypesAsync(CatalogResourceParameters ctgResourcePrms) { return(await _catalogRepository.GetCatalogTypesAsync(ctgResourcePrms)); }