// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCors(options => options.AllowAnyOrigin()); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); using var serviceScope = app.ApplicationServices.CreateScope(); LiquidApiContext context = serviceScope.ServiceProvider.GetService <LiquidApiContext>(); DataSeed.AddSeedData(context); }
public static void AddSeedData(LiquidApiContext context) { Customer chris = new Customer { EmailAddress = "*****@*****.**", FirstName = "Christopher", LastName = "Walken", Address = new Address { City = "Beverly Hills", Country = "USA", Line1 = "363 Copa De Oro Rd", PostalCode = "90210", StateOrProvince = "CA" } }; Customer brooke = new Customer { EmailAddress = "*****@*****.**", FirstName = "Brooke", LastName = "Shields", Address = new Address { City = "New York", Country = "USA", Line1 = "225 W 10th St", PostalCode = "10014", StateOrProvince = "NY" } }; context.Customers.Add(chris); Console.WriteLine($"[SEED] Added customer: {JsonConvert.SerializeObject(chris, Formatting.Indented)}"); context.Customers.Add(brooke); Console.WriteLine($"[SEED] Added customer: {JsonConvert.SerializeObject(brooke, Formatting.Indented)}"); context.SaveChanges(); }
public CustomerRepository(LiquidApiContext context) { _context = context; }
public AddressRepository(LiquidApiContext context) { _context = context; }