コード例 #1
0
        //Update
        public bool UpdateIngredient(string originalIngredient, IngredientsContent newIngredient)
        {
            IngredientsContent oldIngredient = GetIngredientByName(originalIngredient);

            if (oldIngredient != null)
            {
                oldIngredient.IngredientName = newIngredient.IngredientName;
                return(true);
            }
            else
            {
                return(false);
            }

            int initialCount = _listOfIngredients.Count;

            _listOfIngredients.Remove(oldIngredient);

            if (initialCount > _listOfIngredients.Count)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        //Delete
        public bool RemoveIngredient(string ingredientName)
        {
            IngredientsContent ingredient = GetIngredientByName(ingredientName);

            if (ingredient == null)
            {
                return(false);
            }

            int initialCount = _listOfIngredients.Count;

            _listOfIngredients.Remove(ingredient);

            if (initialCount > _listOfIngredients.Count)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
 //Create
 public void AddIngredient(IngredientsContent content)
 {
     _listOfIngredients.Add(content);
 }