public static void AddSeeds(IApplicationBuilder app) { AppDatabase tempDatabase = app.ApplicationServices.GetRequiredService <AppDatabase>(); tempDatabase.Database.Migrate(); if (!tempDatabase.PackofRecipes.Any()) { tempDatabase.PackofRecipes.AddRange( new Recipe() { Chef = "StevenDion", Name = "Chicken Cesar Salad", Description = "A Caesar salad is a green salad of romaine lettuce and croutons dressed with lemon juice," + " olive oil, egg, Worcestershire sauce, anchovies, garlic, Dijon mustard, Parmesan cheese, and black pepper." + " In its original form, this salad was prepared and served tableside. ", PreparationTime = "15", Ingredient = " 1 pound (454 grams) cooked chicken breast\r\n " + "1 head of Lettuce\r\n " + "2 tablespoon freshly squeezed lemon juice\r\n " }, new Recipe() { Chef = "Mark Dion", Name = "Rotten Fish Salad", Description = "A Fish salad is a nasty salad of lettuce and dont make any sense. Contains egg, Worcestershire sauce, anchovies," + " garlic, Dijon mustard, Feta cheese, and black pepper.", PreparationTime = "15", Ingredient = " 1 pound (454 grams) cooked Fish rotten\r\n " + "1 head of Lettuce\r\n " + "2 tablespoon freshly squeezed lemon juice\r\n " } ); } tempDatabase.SaveChanges(); }
public void updateRecipe(Recipe theRecipe) { if (theRecipe.RecipeID == 0) { context.PackofRecipes.Add(theRecipe); } else { Recipe newEntry = context.PackofRecipes .FirstOrDefault(p => p.RecipeID == theRecipe.RecipeID); if (newEntry != null) { newEntry.Name = theRecipe.Name; newEntry.Description = theRecipe.Description; newEntry.Chef = theRecipe.Chef; newEntry.PreparationTime = theRecipe.PreparationTime; newEntry.Ingredient = theRecipe.Ingredient; } } context.SaveChanges(); }