예제 #1
0
        /// <summary>
        /// We remove the deleted ingredient id from the recipes.
        /// </summary>
        /// <param name="ingredient"></param>
        void HandleDeletedIngredient(Ingredients ingredient)
        {
            List <Recipes> recipes = MongoManager.Where <Recipes>(x => x.Ingredients.Any(x => x._id == ingredient._id));

            foreach (var recipe in recipes)
            {
                recipe.Ingredients.RemoveAll(x => x._id == ingredient._id);
                recipe.Save();
            }

            MongoManager.DeleteItems <IngredientPrices>(x => x.IngredientId == ingredient._id);
        }