private void GetDataFromFolder(string folder) { Folder = folder; JsonManager json = new JsonManager(); foreach (string file in Directory.GetFiles(Folder, "*.json")) { Recipe recipeX = (Recipe)json.LoadObject(file); if (recipeX != null) { AllRecipesList.Add(recipeX); } } }
private void AddRecipeToDataBase() { bool fileAdded = false; // Create productName.json file, Add all informations (Name, Kcal, Fat etc...) in json format. do { JsonManager json = new JsonManager(); json.SaveObject(NewRecipe, GeneratePath(NewRecipe.Name)); if (json.SaveSucced()) { fileAdded = true; AllRecipesList.Add(NewRecipe); } else { Console.WriteLine("Try again."); NewRecipe.Name = Console.ReadLine(); } } while (fileAdded == false); }