/// <summary> /// In memory database seed /// </summary> private void SetupHarryPotterDiscounts() { using (var context = new BillingContext(options)) { // Products var p1 = new Product() { Id = 1, Name = "Harry Potter Book 1", Price = 10, SKU = "potter1", isHarryPotter = true }; var p2 = new Product() { Id = 2, Name = "Harry Potter Book 2", Price = 10, SKU = "potter2", isHarryPotter = true }; var p3 = new Product() { Id = 3, Name = "Harry Potter Book 3", Price = 10, SKU = "potter3", isHarryPotter = true }; var p4 = new Product() { Id = 4, Name = "Harry Potter Book 4", Price = 10, SKU = "potter4", isHarryPotter = true }; var p5 = new Product() { Id = 5, Name = "Harry Potter Book 5", Price = 10, SKU = "potter5", isHarryPotter = true }; var p6 = new Product() { Id = 6, Name = "Harry Potter Book 6", Price = 10, SKU = "potter6", isHarryPotter = true }; var p7 = new Product() { Id = 7, Name = "Harry Potter Book 7", Price = 10, SKU = "potter7", isHarryPotter = true }; var potterBooks = new List <Product> { p1, p2, p3, p4, p5, p6, p7 }; context.AddRange(potterBooks); // Discounts var d1 = new Discount() { Id = 1, MinProductsRequired = 2, Percent = 0.05 }; AddDiscountProduct(d1, p1); AddDiscountProduct(d1, p2); AddDiscountProduct(d1, p3); AddDiscountProduct(d1, p4); AddDiscountProduct(d1, p5); AddDiscountProduct(d1, p6); AddDiscountProduct(d1, p7); var d2 = new Discount() { Id = 2, MinProductsRequired = 3, Percent = 0.10, }; AddDiscountProduct(d2, p1); AddDiscountProduct(d2, p2); AddDiscountProduct(d2, p3); AddDiscountProduct(d2, p4); AddDiscountProduct(d2, p5); AddDiscountProduct(d2, p6); AddDiscountProduct(d2, p7); var d3 = new Discount() { Id = 3, MinProductsRequired = 4, Percent = 0.20 }; AddDiscountProduct(d3, p1); AddDiscountProduct(d3, p2); AddDiscountProduct(d3, p3); AddDiscountProduct(d3, p4); AddDiscountProduct(d3, p5); AddDiscountProduct(d3, p6); AddDiscountProduct(d3, p7); var d4 = new Discount() { Id = 4, MinProductsRequired = 5, Percent = 0.25 }; AddDiscountProduct(d4, p1); AddDiscountProduct(d4, p2); AddDiscountProduct(d4, p3); AddDiscountProduct(d4, p4); AddDiscountProduct(d4, p5); AddDiscountProduct(d4, p6); AddDiscountProduct(d4, p7); context.Add(d1); context.Add(d2); context.Add(d3); context.Add(d4); context.SaveChanges(); } }