Exemplo n.º 1
0
        /// <summary>
        /// Deleting the recipe will also remove any assocated ingredients from the database.
        /// </summary>
        /// <param name="recipeId"></param>
        public void Delete(long recipeId)
        {
            Recipe recipe = Get(recipeId);

            recipeRepository.Remove(recipe);
            recipeRepository.SaveChanges();

            recipe = null;
        }
        public void Delete(long id)
        {
            Ingredient ingredient = Get(id);

            ingredientRepository.Remove(ingredient);
            ingredientRepository.SaveChanges();

            ingredient = null;
        }
        public void Delete(long recipeFamilyID)
        {
            RecipeFamily recipeFamily = Get(recipeFamilyID);

            IEnumerable <long> recipeIDs = GetAllRecipeVariants(recipeFamily.Id).Select(r => r.Id);

            foreach (long id in recipeIDs)
            {
                //Let the Recipe Service deal with removing all information for the recipe
                recipeService.Delete(id);
            }

            //At this point, no child objects/data remain that are associated with recipeFamily

            recipeFamilyRepository.Remove(recipeFamily);
            recipeFamilyRepository.SaveChanges();

            //null out the references to completely remove the objects from memeory.

            recipeIDs    = null;
            recipeFamily = null;
        }