Yes, the problem is with the way you are populating your view model. You must initialize the lists and then add items to them:
private MenuViewModel LoadViewModel(int menuNameID)
{
List<Category> returnedCategories = GetAllMenuDataModel.GetAllMenuItemsByCategory(menuNameID);
MenuViewModel vmMenu = new MenuViewModel();
vmMenu.CategoryList = new List<CategoryViewModel>();
foreach (Category category in returnedCategories)
{
CategoryViewModel vmCategory = new CategoryViewModel
{
CategoryID = category.categoryId,
CategoryTitle = category.categoryTitle
};
vmCategory.MenuItemList = new List<MenuItemViewModel>();
foreach (MenuItem menuItem in category.MenuItems)
{
MenuItemViewModel vmMenuItem = new MenuItemViewModel
{
Title = menuItem.itemTitle,
Description = menuItem.itemDescription,
Note = menuItem.itemNote
};
vmMenuItem.PriceList = new List<PriceViewModel>();
foreach (Price price in menuItem.Prices)
{
PriceViewModel vmPrices = new PriceViewModel();
switch (price.MealType.mealName.ToLower())
{
case "lunch":
if (price.ServingSize.sizeName == "Regular")
{
vmPrices.PriceValueLargeLunch = price.priceValue;
}
if (price.ServingSize.sizeName == "Small")
{
vmPrices.PriceValueLargeLunch = price.priceValue;
}
if (price.ServingSize.sizeName == "Large")
{
vmPrices.PriceValueLargeLunch = price.priceValue;
}
break;
case "dinner":
if (price.ServingSize.sizeName == "Regular")
{
vmPrices.PriceValueLargeLunch = price.priceValue;
}
if (price.ServingSize.sizeName == "Small")
{
vmPrices.PriceValueLargeLunch = price.priceValue;
}
if (price.ServingSize.sizeName == "Large")
{
vmPrices.PriceValueLargeLunch = price.priceValue;
}
break;
case "takeOut":
if (price.ServingSize.sizeName == "Regular")
{
vmPrices.PriceValueLargeLunch = price.priceValue;
}
if (price.ServingSize.sizeName == "Small")
{
vmPrices.PriceValueLargeLunch = price.priceValue;
}
if (price.ServingSize.sizeName == "Large")
{
vmPrices.PriceValueLargeLunch = price.priceValue;
}
break;
}
vmMenuItem.PriceList.Add(vmPrices);
}
vmCategory.MenuItemList.Add(vmMenuItem);
}
vmMenu.CategoryList.Add(vmCategory);
}
return vmMenu;
}