Example #1
0
        private UnitTranslationSet _UnitTranslations;   //related to Units

        //Constructors
        public AllDataSets()
        {
            _Units             = new UnitSet();
            _UnitTranslations  = new UnitTranslationSet(_Units);
            _Ingredients       = new IngredientSet(_Units);
            _Recipes           = new RecipeSet(_Units, _Ingredients);
            _FoodPlanItems     = new FoodPlanItemSet();
            _ShoppingListItems = new ShoppingListItemSet();
            SetDataReference();
        }
Example #2
0
        public ShoppingListItemSet OpenSet(string FileName)
        {
            ShoppingListItemSet ReturnUnitSet = this;

            ReturnUnitSet.Clear();
            FileName += FileExtension;
            using (Stream fs = new FileStream(FileName, FileMode.Open))
            {
                System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(ReturnUnitSet.GetType());
                ReturnUnitSet = (ShoppingListItemSet)x.Deserialize(fs);
            }

            EvaluateMaxID();
            return(ReturnUnitSet);
        }// --> Data
Example #3
0
        public AllDataSets(bool ToBePopulatedWithDefaults)
        {
            _Units = new UnitSet();

            _UnitTranslations  = new UnitTranslationSet(_Units);
            _Ingredients       = new IngredientSet(_Units);
            _Recipes           = new RecipeSet(_Units, _Ingredients);
            _FoodPlanItems     = new FoodPlanItemSet();
            _ShoppingListItems = new ShoppingListItemSet();
            SetDataReference();
            if (ToBePopulatedWithDefaults)
            {
                PopulateSetWithDefaults();
            }
        }
Example #4
0
        public void TransferToShoppingList(ShoppingListItemSet ShoppingListItems)
        {
            ShoppingListItem newItem;
            double           quantityFactor;

            foreach (FoodPlanItem ListItem in this)
            {
                quantityFactor = ListItem.TotalPortions / ListItem.PlannedRecipe.PortionQuantity;

                foreach (RecipeIngredient RecipeIngredient in ListItem.PlannedRecipe.Ingredients)
                {
                    newItem                      = new ShoppingListItem();
                    newItem.Quantity             = quantityFactor * RecipeIngredient.Quantity;
                    newItem.Unit                 = RecipeIngredient.Unit;
                    newItem.Ingredient           = RecipeIngredient.Ingredient;
                    newItem.ReferredFoodPlanItem = ListItem;
                    ShoppingListItems.AddItem(newItem);
                }
            }
        }