Hi Bill Mackin,
Thank you for reaching out to Microsoft Q & A forum.
It appears that the issue with GetPizzasAsync() is due to a missing return statement, which results in the error message 'PizzaService.GetPizzasAsync()': not all code paths return a value. This happens because the code section in the tutorial includes a placeholder comment (// Call your data access technology here), but doesn’t include a complete example with a return statement
To resolve this, you can add a temporary return value with some sample data. Here’s an example that will allow you to proceed without errors:
public Task<Pizza[]> GetPizzasAsync()
{
// Sample data to ensure the method compiles
return Task.FromResult(new Pizza[]
{
new Pizza { PizzaId = 1, Name = "Margherita", Description = "Classic", Price = 9.99m, Vegetarian = true, Vegan = false },
new Pizza { PizzaId = 2, Name = "Pepperoni", Description = "Spicy and savory", Price = 12.99m, Vegetarian = false, Vegan = false }
});
}
This code provides placeholder pizza data, which can be replaced later with actual data from a database or other data source when you’re ready to integrate it.
Please feel free to contact us if you have any additional questions.
If you have found the answer provided to be helpful, please click on the "Accept answer/Upvote" button so that it is useful for other members in the Microsoft Q&A community.