Example #1
0
        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);
        }
Example #2
0
 public static void Initialize(IServiceProvider serviceProvider)
 {
     using (var context = new ST4MPContext(serviceProvider.GetRequiredService <DbContextOptions <ST4MPContext> >()))
     {
         if (context.Customers.Any())
         {
             return;
         }
         GetData(context);
         context.SaveChanges();
     }
 }
Example #3
0
 public ShopsController(ST4MPContext context)
 {
     _context = context;
 }
Example #4
0
 public CustomersController(ST4MPContext context)
 {
     _context = context;
 }