public static void GetData(ST4MPContext context) { String customerString = File.ReadAllText("./Data/customers.json"); String shopsString = File.ReadAllText("./Data/shops.json"); List <Customers> customers = JsonConvert.DeserializeObject <List <Customers> >(customerString); List <Shops> shops = JsonConvert.DeserializeObject <List <Shops> >(shopsString); context.AddRange(customers); context.AddRange(shops); }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new ST4MPContext(serviceProvider.GetRequiredService <DbContextOptions <ST4MPContext> >())) { if (context.Customers.Any()) { return; } GetData(context); context.SaveChanges(); } }
public ShopsController(ST4MPContext context) { _context = context; }
public CustomersController(ST4MPContext context) { _context = context; }