//Creates a dictionary by coping all fooditems from fis to FoodItemsByCategory where the category matches public void LoadFoodItemsByCategory(List <FoodItem> fis) { if (fis == null) { return; } if (FoodItemsByCategory == null) { FoodItemsByCategory = new Dictionary <FoodItemCategory, List <FoodItem> >(); } foreach (FoodItemCategory fic in ALL_FOOD_ITEM_CATEGORIES) { FoodItemsByCategory.Add(fic, new List <FoodItem>()); } foreach (FoodItem fi in fis) { foreach (FoodItemCategory cat in fi.Category) { FoodItemsByCategory[cat].Add(new FoodItem(fi)); } } }
private async void GetFoodItems(int categoryID) { var data = await new FoodItemService().GetFoodItemsByCategoryAsync(categoryID); FoodItemsByCategory.Clear(); foreach (var item in data) { FoodItemsByCategory.Add(item); } TotalFoodItems = FoodItemsByCategory.Count; }