Grocer.ly Project from ASP.NET Course

Hello Everyone,

In the Grocer.ly project for the ASP.NET course (the final exercise in the Page Models section), instruction number 2 says:

" We’ll need to access each grocery item in the page model for the home page.

In Pages/Index.cshtml.cs , define a Foods field that stores the result of Inventory.ToList() .

( Inventory is a static class, and can be accessed by the IndexModel directly.)"

The provided hint says:

“Remember that Inventory.ToList() has a return type of List<GroceryItem> .”

I have declared Foods thus in Index.cshtml.cs:

namespace GroceryStore.Pages
{
  public class IndexModel : PageModel
  {

    [BindProperty]
    public int Rating { get; set; }
    [BindProperty]
    public string Feedback { get; set; }
    [BindProperty]
    public List<GroceryItem> Foods { get; set; }

    public void OnGet()
    {
    
    }

  }
}

I’ve played around with it a few other ways as well. Nothing renders on the webpage. I get the following message in the console:

Pages/Index.cshtml(13,12): error CS0246: The type or namespace name 'Foods' could not be found (are you missing a using directive or an assembly reference?) [/home/ccuser/workspace/aspnet-grocery-store/GroceryStore.csproj]

Inventory and ToList() are already written by Codecademy in Inventory.cs, so the mistake must be coming from my code, above. Can anyone provide insight into how I should complete the instructions in order to see the data properly render?

Thanks much!
-Justin

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.