internal static IQueryable<RecipeCategory> RecipeCategories(KRSContext context) { var list = new List<RecipeCategory> { new RecipeCategory { Name = "Категорії рецептів", Description = TextGenerator.GenSentences(10, DescTextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, }, new RecipeCategory { Name = "Українська кухня", Description = TextGenerator.GenSentences(10, DescTextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, PhotoPath = "~/Images/GroupCategories/Recipes/ukr.jpg", Group = context.CategoryTypes.FirstOrDefault(x => x.Name=="Національна приналежність"), }, new RecipeCategory { Name = "Російська кухня", Description = TextGenerator.GenSentences(10, DescTextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, PhotoPath = "~/Images/GroupCategories/Recipes/rus.jpg", Group = context.CategoryTypes.FirstOrDefault(x => x.Name=="Національна приналежність"), }, new RecipeCategory { Name = "Казахська кухня", Description = TextGenerator.GenSentences(10, DescTextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, PhotoPath = "~/Images/GroupCategories/Recipes/kazak.jpg", Group = context.CategoryTypes.FirstOrDefault(x => x.Name=="Національна приналежність"), }, new RecipeCategory { Name = "Авторські страви", Description = TextGenerator.GenSentences(10, DescTextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, PhotoPath = "~/Images/GroupCategories/Recipes/avtorski-stravu.jpg", Group = context.CategoryTypes.FirstOrDefault(x => x.Name=="Типи страв"), }, new RecipeCategory { Name = "Напитки", Description = TextGenerator.GenSentences(10, DescTextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, PhotoPath = "~/Images/GroupCategories/Recipes/beverages.jpg", Group = context.CategoryTypes.FirstOrDefault(x => x.Name=="Типи страв"), }, new RecipeCategory { Name = "Десерти", Description = TextGenerator.GenSentences(10, DescTextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, PhotoPath = "~/Images/GroupCategories/Recipes/desertu.jpg", Group = context.CategoryTypes.FirstOrDefault(x => x.Name=="Типи страв"), }, new RecipeCategory { Name = "Другі страви", Description = TextGenerator.GenSentences(10, DescTextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, PhotoPath = "~/Images/GroupCategories/Recipes/drugi-stravu.jpg", Group = context.CategoryTypes.FirstOrDefault(x => x.Name=="Типи страв"), }, new RecipeCategory { Name = "Грузинська кухня", Description = TextGenerator.GenSentences(10, DescTextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, PhotoPath = "~/Images/GroupCategories/Recipes/georgia.jpg", Group = context.CategoryTypes.FirstOrDefault(x => x.Name=="Національна приналежність"), }, new RecipeCategory { Name = "Соки", Description = TextGenerator.GenSentences(10, DescTextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, PhotoPath = "~/Images/GroupCategories/Recipes/juses.jpg", Group = context.CategoryTypes.FirstOrDefault(x => x.Name=="Типи страв"), }, new RecipeCategory { Name = "Перші страви", Description = TextGenerator.GenSentences(10, DescTextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, PhotoPath = "~/Images/GroupCategories/Recipes/pershi-stravu.jpg", Group = context.CategoryTypes.FirstOrDefault(x => x.Name=="Типи страв"), }, new RecipeCategory { Name = "Салати", Description = TextGenerator.GenSentences(10, DescTextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, PhotoPath = "~/Images/GroupCategories/Recipes/salads.jpg", Group = context.CategoryTypes.FirstOrDefault(x => x.Name=="Типи страв"), }, new RecipeCategory { Name = "Соуси", Description = TextGenerator.GenSentences(10, DescTextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, PhotoPath = "~/Images/GroupCategories/Recipes/soysu.jpg", Group = context.CategoryTypes.FirstOrDefault(x => x.Name=="Типи страв"), }, new RecipeCategory { Name = "Випічка", Description = TextGenerator.GenSentences(10, DescTextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, PhotoPath = "~/Images/GroupCategories/Recipes/vupichka.jpg", Group = context.CategoryTypes.FirstOrDefault(x => x.Name=="Типи страв"), }, new RecipeCategory { Name = "Закуски", Description = TextGenerator.GenSentences(10, DescTextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, PhotoPath = "~/Images/GroupCategories/Recipes/zakuski.jpg", Group = context.CategoryTypes.FirstOrDefault(x => x.Name=="Типи страв"), }, new RecipeCategory { Name = "Вина", Description = TextGenerator.GenSentences(10, DescTextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, PhotoPath = "~/Images/GroupCategories/Recipes/vines.jpg", Group = context.CategoryTypes.FirstOrDefault(x => x.Name=="Типи страв"), }, }; return list.AsQueryable(); }
internal static IQueryable<Kitchenware> Kitchenwares(KRSContext context) { var list = new List<Kitchenware> { new Kitchenware { Name = "Кастрюля", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Description = TextGenerator.GenSentences(3,TextSource), Category = context.KitchenwareCategories.FirstOrDefault(c=>c.Name=="Кастрюлі"), PhotoPath = "~/Images/RecipeParts/Kitchenwares/pan.jpg", }, new Kitchenware { Name = "Сковорода", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Description = TextGenerator.GenSentences(3,TextSource), Category = context.KitchenwareCategories.FirstOrDefault(c=>c.Name=="Сковорідки"), PhotoPath = "~/Images/RecipeParts/Kitchenwares/fray.jpg", Material = "Тефлон", }, new Kitchenware { Name = "Тарілка столова", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Description = TextGenerator.GenSentences(3,TextSource), Category = context.KitchenwareCategories.FirstOrDefault(c=>c.Name=="Тарілки"), PhotoPath = "~/Images/RecipeParts/Kitchenwares/plate.jpg", }, new Kitchenware { Name = "Кухонний комбайн", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Description = TextGenerator.GenSentences(3,TextSource), Category = context.KitchenwareCategories.FirstOrDefault(c=>c.Name=="Електричні прибори"), PhotoPath = "~/Images/RecipeParts/Kitchenwares/combain.jpg", }, new Kitchenware { Name = "Дошка для нарізання", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Description = TextGenerator.GenSentences(3,TextSource), Category = context.KitchenwareCategories.FirstOrDefault(c=>c.Name=="Обладнання"), PhotoPath = "~/Images/RecipeParts/Kitchenwares/doshka.jpg", }, new Kitchenware { Name = "Ніж для мяса", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Description = TextGenerator.GenSentences(3,TextSource), Category = context.KitchenwareCategories.FirstOrDefault(c=>c.Name=="Ножі"), PhotoPath = "~/Images/RecipeParts/Kitchenwares/knife1.jpg", }, new Kitchenware { Name = "Ніж для овочів", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Description = TextGenerator.GenSentences(3,TextSource), Category = context.KitchenwareCategories.FirstOrDefault(c=>c.Name=="Ножі"), PhotoPath = "~/Images/RecipeParts/Kitchenwares/knife2.jpg", }, new Kitchenware { Name = "Ніж для риби", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Description = TextGenerator.GenSentences(3,TextSource), Category = context.KitchenwareCategories.FirstOrDefault(c=>c.Name=="Ножі"), PhotoPath = "~/Images/RecipeParts/Kitchenwares/knife3.jpg", }, new Kitchenware { Name = "Мясорубка", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Description = TextGenerator.GenSentences(3,TextSource), Category = context.KitchenwareCategories.FirstOrDefault(c=>c.Name=="Електричні прибори"), PhotoPath = "~/Images/RecipeParts/Kitchenwares/meatcut.jpg", }, new Kitchenware { Name = "Міксер", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Description = TextGenerator.GenSentences(3,TextSource), Category = context.KitchenwareCategories.FirstOrDefault(c=>c.Name=="Електричні прибори"), PhotoPath = "~/Images/RecipeParts/Kitchenwares/mixer.jpg", }, new Kitchenware { Name = "Піднос", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Description = TextGenerator.GenSentences(3,TextSource), Category = context.KitchenwareCategories.FirstOrDefault(c=>c.Name=="Обладнання"), PhotoPath = "~/Images/RecipeParts/Kitchenwares/pidnos.jpg", }, new Kitchenware { Name = "Штопор", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Description = TextGenerator.GenSentences(3,TextSource), Category = context.KitchenwareCategories.FirstOrDefault(c=>c.Name=="Обладнання"), PhotoPath = "~/Images/RecipeParts/Kitchenwares/shtopor.jpg", }, new Kitchenware { Name = "Відкривачка для консерацій", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Description = TextGenerator.GenSentences(3,TextSource), Category = context.KitchenwareCategories.FirstOrDefault(c=>c.Name=="Відкривачки"), PhotoPath = "~/Images/RecipeParts/Kitchenwares/vidkruvach.jpg", }, }; return list.AsQueryable(); }
public static void InitializeDb(KRSContext context) { var photos = PhotosCollection.Photos(); photos.ToList().ForEach(s => context.Photos.AddOrUpdate(s)); context.SaveChanges(); var recipeCategoriesTypes = CategoriesCollection.RecipeCategoryTypes(); recipeCategoriesTypes.ToList().ForEach(s => context.CategoryTypes.AddOrUpdate(s)); context.SaveChanges(); var ingredientCategories = CategoriesCollection.IngredientsCategories(); ingredientCategories.ToList().ForEach(s => context.IngredientCategories.AddOrUpdate(s)); var kitchenwareCategories = CategoriesCollection.KitchenwareCategories(); kitchenwareCategories.ToList().ForEach(s => context.KitchenwareCategories.AddOrUpdate(s)); var recipeCategories = CategoriesCollection.RecipeCategories(context); recipeCategories.ToList().ForEach(s => context.RecipeCategories.AddOrUpdate(s)); context.SaveChanges(); var ingredients = IngredientsCollection.Ingredients(context); foreach (var ingredient in ingredients) { ingredient.Photos = RandomSelector.Deal(context.Photos.ToList(), 5); } ingredients.ToList().ForEach(s => context.Ingredients.AddOrUpdate(s)); var kitchenwares = KitchenwareCollection.Kitchenwares(context); kitchenwares.ToList().ForEach(s => context.Kitchenwares.AddOrUpdate(s)); var cookProcesses = CookProcessesCollection.CookProcesses(); cookProcesses.ToList().ForEach(s => context.CookProcesses.AddOrUpdate(s)); context.SaveChanges(); var recipes = RecipesCollection.Recipes(context); recipes.ToList().ForEach(s => context.Recipes.AddOrUpdate(s)); context.SaveChanges(); var rand = new Random(); foreach (var recipe in context.Recipes.ToList()) { recipe.Photos = RandomSelector.Deal(context.Photos.ToList(), 6); List<Ingredient> recipeIngredients = RandomSelector.Deal(context.Ingredients.ToList(), 7); foreach (var recipeIngredient in recipeIngredients) { var schema = new RecipesIngredients { Step = rand.Next(1, 7), Recipe = recipe, Ingredient = recipeIngredient, Unit = new MeasurementUnit { MeasureSign = "одиниць", Value = rand.Next(1, 100).ToString(CultureInfo.InvariantCulture), } }; context.RecipesIngredients.Add(schema); recipe.IngredientsRelation.Add(schema); recipeIngredient.IngredientRecipes.Add(schema); } context.SaveChanges(); List<Kitchenware> recipeKitchenware = RandomSelector.Deal(context.Kitchenwares.ToList(), 4); foreach (var recipeKware in recipeKitchenware) { var schema = new RecipesKitchenwares { Step = rand.Next(1, 7), Recipe = recipe, Kitchenware = recipeKware, Quontity = rand.Next(1, 4), }; context.RecipesKitchenwares.Add(schema); recipe.KitchenwaresRelation.Add(schema); recipeKware.KitchenwareRecipes.Add(schema); } context.SaveChanges(); List<CookProcess> recipeCookProesses = RandomSelector.Deal(context.CookProcesses.ToList(), 5); foreach (var recipeCookProc in recipeCookProesses) { var schema = new RecipesCookProcesses { Step = rand.Next(1, 7), Recipe = recipe, CookProcess = recipeCookProc, }; context.RecipesCookProcesses.Add(schema); recipe.CookProcessesRelation.Add(schema); recipeCookProc.CookProcessRecipes.Add(schema); } context.SaveChanges(); } }
public static IQueryable<Recipe> Recipes(KRSContext context) { var list = new List<Recipe> { new Recipe { Name = "Грейпфруктовий соус", PhotoPath = "~/Images/Recipes/greyprutovyj-sous.jpg", ShortDescription = TextGenerator.GenSentences(1,TextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Likes = 2, Dislikes = 0, Categories = new List<RecipeCategory> { context.RecipeCategories.FirstOrDefault(c => c.Name == "Соуси"), context.RecipeCategories.FirstOrDefault(c => c.Name == "Грузинська кухня"), }, ExtRecipe = new ExtRecipe { FullDescription = TextGenerator.GenSentences(15, SampleTextGenerator.SourceNames.Decameron) } }, new Recipe { Name = "Курка по Китайське", PhotoPath = "~/Images/Recipes/kuryache-file-kitaysky.jpg", ShortDescription = TextGenerator.GenSentences(1,TextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Likes = 2, Dislikes = 0, Categories = new List<RecipeCategory> { context.RecipeCategories.FirstOrDefault(c => c.Name == "Другі страви"), context.RecipeCategories.FirstOrDefault(c => c.Name == "Грузинська кухня"), }, ExtRecipe = new ExtRecipe { FullDescription = TextGenerator.GenSentences(15, SampleTextGenerator.SourceNames.Decameron) } }, new Recipe { Name = "Бутерброди з ікрою і авокадо", PhotoPath = "~/Images/Recipes/mini-buterbrody-ikroyu-avokado.jpg", ShortDescription = TextGenerator.GenSentences(1,TextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Likes = 2, Dislikes = 0, Categories = new List<RecipeCategory> { context.RecipeCategories.FirstOrDefault(c => c.Name == "Закуски"), context.RecipeCategories.FirstOrDefault(c => c.Name == "Авторські страви"), }, ExtRecipe = new ExtRecipe { FullDescription = TextGenerator.GenSentences(15, SampleTextGenerator.SourceNames.Decameron) } }, new Recipe { Name = "Мясо по французьки", PhotoPath = "~/Images/Recipes/myaso-francuzky.jpg", ShortDescription = TextGenerator.GenSentences(1,TextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Likes = 2, Dislikes = 0, Categories = new List<RecipeCategory> { context.RecipeCategories.FirstOrDefault(c => c.Name == "Другі страви"), context.RecipeCategories.FirstOrDefault(c => c.Name == "Російська кухня"), }, ExtRecipe = new ExtRecipe { FullDescription = TextGenerator.GenSentences(15, SampleTextGenerator.SourceNames.Decameron) } }, new Recipe { Name = "Салат Шопський", PhotoPath = "~/Images/Recipes/saladshopsky.jpg", ShortDescription = TextGenerator.GenSentences(1,TextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Likes = 2, Dislikes = 0, Categories = new List<RecipeCategory> { context.RecipeCategories.FirstOrDefault(c => c.Name == "Салати"), context.RecipeCategories.FirstOrDefault(c => c.Name == "Українська кухня"), }, ExtRecipe = new ExtRecipe { FullDescription = TextGenerator.GenSentences(15, SampleTextGenerator.SourceNames.Decameron) } }, new Recipe { Name = "Вінігрет", PhotoPath = "~/Images/Recipes/vinegret.jpg", ShortDescription = TextGenerator.GenSentences(1,TextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Likes = 2, Dislikes = 0, Categories = new List<RecipeCategory> { context.RecipeCategories.FirstOrDefault(c => c.Name == "Салати"), context.RecipeCategories.FirstOrDefault(c => c.Name == "Російська кухня"), }, ExtRecipe = new ExtRecipe { FullDescription = TextGenerator.GenSentences(15, SampleTextGenerator.SourceNames.Decameron) } }, new Recipe { Name = "Десерти з сухофруктів", PhotoPath = "~/Images/Recipes/cukerky-suhofruktiv.jpg", ShortDescription = TextGenerator.GenSentences(1,TextSource), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Likes = 2, Dislikes = 0, Categories = new List<RecipeCategory> { context.RecipeCategories.FirstOrDefault(c => c.Name == "Десерти"), context.RecipeCategories.FirstOrDefault(c => c.Name == "Казахська кухня"), }, ExtRecipe = new ExtRecipe { FullDescription = TextGenerator.GenSentences(15, SampleTextGenerator.SourceNames.Decameron) } }, }; return list.AsQueryable(); }
public static IQueryable<Ingredient> Ingredients(KRSContext context) { var list = new List<Ingredient> { new Ingredient { Name = "Ранети", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Category = context.IngredientCategories.FirstOrDefault(c => c.Name == "Яблука"), PhotoPath = "~/Images/RecipeParts/Ingredients/apple.jpg", Description = TextGenerator.GenSentences(3, TextSource), Manufacturer = "ВАТ AllFoods", }, new Ingredient { Name = "Апельсини", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Category = context.IngredientCategories.FirstOrDefault(c => c.Name == "Цитрусові"), PhotoPath = "~/Images/RecipeParts/Ingredients/orange.jpg", Description = TextGenerator.GenSentences(3, TextSource), Manufacturer = "ВАТ AllFoods" }, new Ingredient { Name = "Часник", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Category = context.IngredientCategories.FirstOrDefault(c => c.Name == "Овочі"), PhotoPath = "~/Images/RecipeParts/Ingredients/chasnuk.jpg", Description = TextGenerator.GenSentences(3, TextSource), Manufacturer = "ВАТ AllFoods" }, new Ingredient { Name = "Червоний Перець", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Category = context.IngredientCategories.FirstOrDefault(c => c.Name == "Овочі"), PhotoPath = "~/Images/RecipeParts/Ingredients/chili.jpg", Description = TextGenerator.GenSentences(3, TextSource), Manufacturer = "ВАТ AllFoods" }, new Ingredient { Name = "Цибуля звичайна", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Category = context.IngredientCategories.FirstOrDefault(c => c.Name == "Овочі"), PhotoPath = "~/Images/RecipeParts/Ingredients/onion.jpg", Description = TextGenerator.GenSentences(3, TextSource), Manufacturer = "ВАТ AllFoods" }, new Ingredient { Name = "Імбир", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Category = context.IngredientCategories.FirstOrDefault(c => c.Name == "Овочі"), PhotoPath = "~/Images/RecipeParts/Ingredients/imbur.jpg", Description = TextGenerator.GenSentences(3, TextSource), Manufacturer = "ВАТ AllFoods" }, new Ingredient { Name = "Мандарин", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Category = context.IngredientCategories.FirstOrDefault(c => c.Name == "Цитрусові"), PhotoPath = "~/Images/RecipeParts/Ingredients/mandarun.jpg", Description = TextGenerator.GenSentences(3, TextSource), Manufacturer = "ВАТ AllFoods" }, new Ingredient { Name = "Свинина", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Category = context.IngredientCategories.FirstOrDefault(c => c.Name == "Мясо"), PhotoPath = "~/Images/RecipeParts/Ingredients/meat.jpg", Description = TextGenerator.GenSentences(3, TextSource), Manufacturer = "ВАТ AllFoods" }, new Ingredient { Name = "Картопля", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Category = context.IngredientCategories.FirstOrDefault(c => c.Name == "Овочі"), PhotoPath = "~/Images/RecipeParts/Ingredients/potato.jpg", Description = TextGenerator.GenSentences(3, TextSource), Manufacturer = "ВАТ AllFoods" }, new Ingredient { Name = "Болгарський перець", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Category = context.IngredientCategories.FirstOrDefault(c => c.Name == "Овочі"), PhotoPath = "~/Images/RecipeParts/Ingredients/redperec.jpg", Description = TextGenerator.GenSentences(3, TextSource), Manufacturer = "ВАТ AllFoods" }, new Ingredient { Name = "Морква", CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Category = context.IngredientCategories.FirstOrDefault(c => c.Name == "Овочі"), PhotoPath = "~/Images/RecipeParts/Ingredients/carrot.jpg", Description = TextGenerator.GenSentences(3, TextSource), Manufacturer = "ВАТ AllFoods" }, }; return list.AsQueryable(); }