示例#1
0
        public static void UpdateRecipe(List <IngredientByRecipe> ingredientByRecipeList, Recipe recipe, RecipeViewModel recipeView)
        {
            var originalRecipe = recipeView.GetRecipe();
            var database       = new SQLiteDataService();

            database.Initialize();
            database.UpdateRecipe(recipe);
            database.DeleteIngredientsByRecipe(originalRecipe.Id);
            ingredientByRecipeList.ForEach(ibr =>
            {
                ibr.RecipeId = originalRecipe.Id;
                database.AddIngredientByRecipe(ibr);
            });
            database.Close();
            var allUsersRecipesList = AllUsersRecipes.ToList();

            AllUsersRecipes.Clear();
            var index = allUsersRecipesList.IndexOf(recipeView);

            allUsersRecipesList.RemoveAt(index);
            allUsersRecipesList.Insert(index, new RecipeViewModel(recipe));
            allUsersRecipesList.ForEach(rVM => AllUsersRecipes.Add(rVM));
        }