public static void Seed(ClothesDatabaseContext clothesDatabaseContext) { if (!clothesDatabaseContext.Colours.Any()) { List <Colour> seedColours = new List <Colour> { new Colour { Value = "Red" }, new Colour { Value = "Blue" }, new Colour { Value = "Purple" }, new Colour { Value = "Green" } }; clothesDatabaseContext.Colours.AddRange(seedColours); clothesDatabaseContext.SaveChanges(); } }
public static void Seed(ClothesDatabaseContext clothesDatabaseContext) { TestColours.Seed(clothesDatabaseContext); TestSexes.Seed(clothesDatabaseContext); TestSizes.Seed(clothesDatabaseContext); TestTypes.Seed(clothesDatabaseContext); TestClothes.Seed(clothesDatabaseContext); }
public static void Seed(ClothesDatabaseContext clothesDatabaseContext) { if (!clothesDatabaseContext.ClothingSet.Any()) { List <Colour> colours = clothesDatabaseContext.Colours.ToList(); List <Sex> sexes = clothesDatabaseContext.Sexes.ToList(); List <Size> sizes = clothesDatabaseContext.Sizes.ToList(); List <Type> types = clothesDatabaseContext.Types.ToList(); List <Clothes> clothesList = new List <Clothes> { new Clothes { Colours = colours, Description = "This dress is very pretty", Name = "Pretty red dress", Price = 399.95, Sex = sexes[1], Sizes = sizes, Type = types[0] }, new Clothes { Colours = colours, Description = "T-shirt without any motives", Name = "T-shirt", Price = 1299.95, Sex = sexes[0], Sizes = sizes, Type = types[2] }, new Clothes { Colours = colours, Description = "Dress shirt for when you want to get laid", Name = "Dress shirt for men", Price = 800, Sex = sexes[0], Sizes = sizes, Type = types[4] }, }; clothesDatabaseContext.ClothingSet.AddRange(clothesList); } }
public static void Seed(ClothesDatabaseContext clothesDatabaseContext) { if (!clothesDatabaseContext.Sexes.Any()) { List <Sex> seedSexes = new List <Sex> { new Sex { Value = "Male" }, new Sex { Value = "Female" } }; clothesDatabaseContext.Sexes.AddRange(seedSexes); clothesDatabaseContext.SaveChanges(); } }
public static void Seed(ClothesDatabaseContext clothesDatabaseContext) { if (!clothesDatabaseContext.Sizes.Any()) { List <Size> seedSizes = new List <Size> { new Size { Value = "XXS" }, new Size { Value = "XS" }, new Size { Value = "Small" }, new Size { Value = "Medium" }, new Size { Value = "Large" }, new Size { Value = "XL" }, new Size { Value = "XXL" }, }; clothesDatabaseContext.Sizes.AddRange(seedSizes); clothesDatabaseContext.SaveChanges(); } }
public static void Seed(ClothesDatabaseContext clothesDatabaseContext) { if (!clothesDatabaseContext.Types.Any()) { List <Type> seedTypes = new List <Type> { new Type { Value = "Dress" }, new Type { Value = "Pants" }, new Type { Value = "T-Shirt" }, new Type { Value = "Hoodie" }, new Type { Value = "Dress Shirt" }, new Type { Value = "Cardigan" } }; clothesDatabaseContext.Types.AddRange(seedTypes); clothesDatabaseContext.SaveChanges(); } }
private static void SetupClothingContext(ClothesDatabaseContext clothesDatabaseContext) { clothesDatabaseContext.Database.Migrate(); clothesDatabaseContext.Database.EnsureCreated(); TestData.Seed(clothesDatabaseContext); }
public ClothesController(ILogger <ClothesController> logger, ClothesDatabaseContext context) { _logger = logger; _context = context; }