private async Task SeedCake(CakeItDbContext db, ILogger <CakeItDbContext> logger) { var product1 = new Product { CategoryId = 1, Name = "Choco Mint", Price = 23.20m, Description = "A chocolate sponge layered with a mint flavoured cream. Masked with icing cream, chocolate glaze drip and a range of yummy choc mint goodies on top.", Image = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRNPFKz7AZZjPSwn-e7_QwcGdDUVRI1z_fG_gQiSPI4u1wBQShmhA&s" }; var product2 = new Product { CategoryId = 1, Name = "Cherry Blossom", Price = 55.00m, Description = "Chocolate sponge with matcha green tea buttercream. Decorated with 'cherry blossom' pink sea-salted candied popcorn and pink macarons.", Image = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRcSkgiYbXZlj8AmkDwlbE0BkCMsxKR9NlEHcbVKOL3D5WXvQQx6w&s" }; try { await db.AddRangeAsync(new object[] { product1, product2 }); await db.SaveChangesAsync(); } catch (Exception e) { logger.LogDebug(e.Message); } }
private async Task SeedCustomCakesImages(CakeItDbContext db, ILogger <CakeItDbContext> logger) { var product1 = new CustomCakeImg { Side = "White_Chocolate_Cigarettes", Top = "Habana", Img = "https://res.cloudinary.com/cakeit/image/upload/v1545083551/Top_Habana_WhiteCigarettes.png", Name = "Habana" + " " + "White Cigarettes" }; var product2 = new CustomCakeImg { Side = "White_Chocolate_Cigarettes", Top = "Glaszed_Berries", Img = "https://res.cloudinary.com/cakeit/image/upload/v1545225696/Top_GlazedBerries_WhiteCigarettes.png", Name = "Glaszed Berries" + " " + "White Cigarettes" }; try { await db.AddRangeAsync(new object[] { product1, product2 }); await db.SaveChangesAsync(); } catch (Exception e) { logger.LogDebug(e.Message); } }
private async Task SeedCategories(CakeItDbContext db, IServiceProvider provider) { var logger = provider.GetService <ILogger <CakeItDbContext> >(); var cake = new Category(); cake.Type = (CategoryType)Enum.Parse(typeof(CategoryType), "Cake"); await db.AddAsync(cake); var customCake = new Category(); customCake.Type = (CategoryType)Enum.Parse(typeof(CategoryType), "CustomCake"); await db.AddAsync(customCake); try { await db.SaveChangesAsync(); } catch (Exception e) { logger.LogError(e.Message); } }
private async Task SeedUser(CakeItDbContext db) { db.Users.Add(user); await db.SaveChangesAsync(); }