public async Task <ActionResult <PagedCollection <RecipeResource> > > ListAllRecipes( [FromQuery] SpecificationOptions <RecipeResource> options) { options ??= new SpecificationOptions <RecipeResource>(); options.Paging ??= defaultPagingOptions; options.Paging.Offset ??= defaultPagingOptions.Offset; options.Paging.Limit ??= defaultPagingOptions.Limit; var spec = new Specification <RecipeResource>(options); var recipes = await recipeService.ListAsync(spec).ConfigureAwait(false); return(PagedCollectionHelper.Create( Link.ToCollection(nameof(ListAllRecipes)), recipes.Items.ToArray(), recipes.TotalSize, options.Paging)); }
public async Task <ActionResult <PagedCollection <IngredientResource> > > ListAllUserIngredients( [FromQuery] SpecificationOptions <IngredientResource> options) { options ??= new SpecificationOptions <IngredientResource>(); options.Paging ??= defaultPagingOptions; options.Paging.Offset ??= defaultPagingOptions.Offset; options.Paging.Limit ??= defaultPagingOptions.Limit; var user = await userManager.GetUserAsync(User).ConfigureAwait(false); if (user == null) { return(Forbid()); } var spec = new Specification <IngredientResource>(options); var items = await ingredientService.ListAsync(spec, user.Id).ConfigureAwait(false); return(PagedCollectionHelper.Create( Link.ToCollection(nameof(ListAllUserIngredients)), items.Items.ToArray(), items.TotalSize, options.Paging)); }