public void repopulateSource(BasketMealsRecord[] items) { m_mealDict = new Dictionary <int, BasketTableItem>(); m_selectedItems = new List <NSIndexPath>(); foreach (BasketMealsRecord bmr in items) { //create new table item //BasketTableItem bti = new BasketTableItem(); // get recipe record for meal RecipeMealsRecord rmr = RecipeManager.GetRecipeMealRecord(bmr.RecipeMealsID); // record fo each meal id BasketTableItem bti; string unit = ""; m_mealDict.TryGetValue(rmr.MealID, out bti); if (bti == null) { bti = new BasketTableItem(); MealRecord mr = MealManager.GetMeal(rmr.MealID); bti.m_meal_name = mr.Name; //save units first bti.m_unit = mr.MealDesc; } bti.m_weight += rmr.Qty; bti.m_bmIDs.Add(bmr.ID); m_mealDict[rmr.MealID] = bti; } m_tableItems = new BasketTableItem[m_mealDict.Count]; m_mealDict.Values.CopyTo(m_tableItems, 0); }
public MealTableSrc(RecipeMealsRecord[] items) { m_tableItems = new List <MealTableItem>(); if (items.Length != 0) { m_recipeID = items[0].RecipeID; foreach (RecipeMealsRecord rmr in items) { MealRecord meal = MealManager.GetMeal(rmr.MealID); BasketMealsRecord bmr = BasketManager.GetBasketRecipeRecord(rmr.ID); if (meal != null) { MealTableItem mti = new MealTableItem(); mti.m_meal = meal; mti.m_qty = rmr.Qty; mti.m_bInBasket = bmr == null ? false : true; mti.m_RecMealID = rmr.ID; m_tableItems.Add(mti); } } } }