Exemplo n.º 1
0
 public CreateModel(BravisDbContext db)
 {
     _db = db;
 }
Exemplo n.º 2
0
 public EditModel(BravisDbContext db)
 {
     _db = db;
 }
Exemplo n.º 3
0
 // Using DI to access the Db context.
 public IndexModel(BravisDbContext db)
 {
     _db = db;
 }
Exemplo n.º 4
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new BravisDbContext(
                       serviceProvider.GetRequiredService <DbContextOptions <BravisDbContext> >()))
            {
                // Look for any WorkOrders.
                if (context.WorkOrders.Any())
                {
                    return;   // DB has been seeded
                }

                context.WorkOrders.AddRange(
                    new WorkOrder
                {
                    Name        = "B123",
                    Address     = "Testvägen 2",
                    Description = "Vi ska bygga hus",
                    Start       = "Fakturerat",
                    Status      = "Pågående",
                    SentInvoice = "2017-05-23"
                },

                    new WorkOrder
                {
                    Name        = "B123",
                    Address     = "Testvägen 2",
                    Description = "Vi ska bygga hus",
                    Start       = "Fakturerat",
                    Status      = "Pågående",
                    SentInvoice = "2017-05-23"
                },

                    new WorkOrder
                {
                    Name        = "B123",
                    Address     = "Testvägen 2",
                    Description = "Vi ska bygga hus",
                    Start       = "Fakturerat",
                    Status      = "Pågående",
                    SentInvoice = "2017-05-23"
                },

                    new WorkOrder
                {
                    Name        = "B123",
                    Address     = "Testvägen 2",
                    Description = "Vi ska bygga hus",
                    Start       = "Fakturerat",
                    Status      = "Pågående",
                    SentInvoice = "2017-05-23"
                },

                    new WorkOrder
                {
                    Name        = "B123",
                    Address     = "Testvägen 2",
                    Description = "Vi ska bygga hus",
                    Start       = "Fakturerat",
                    Status      = "Pågående",
                    SentInvoice = "2017-05-23"
                }
                    );
                context.SaveChanges();
            }
        }