Ejemplo n.º 1
0
        public static void EnsurePopulated(IApplicationBuilder app)
        {
            ApplicationDBContent context = app.ApplicationServices
                                           .GetRequiredService <ApplicationDBContent>();

            context.Database.Migrate();

            if (!context.CleverItems.Any())
            {
                context.CleverItems.AddRange(
                    new CleverItem
                {
                    ItemType      = "Lamp",
                    ItemName      = "Lamp in the hall",
                    OverallStatus = true,
                    CurrentStatus = false
                },
                    new CleverItem
                {
                    ItemType      = "Lamp",
                    ItemName      = "Lamp in the kitchen",
                    OverallStatus = false,
                    CurrentStatus = false
                },
                    new CleverItem
                {
                    ItemType      = "Television",
                    ItemName      = "Television in the guestroom",
                    OverallStatus = true,
                    CurrentStatus = false
                },
                    new CleverItem
                {
                    ItemType      = "Television",
                    ItemName      = "Television in the guestroom",
                    OverallStatus = true,
                    CurrentStatus = false
                },
                    new CleverItem
                {
                    ItemType      = "Television",
                    ItemName      = "Television in the guestroom",
                    OverallStatus = true,
                    CurrentStatus = false
                }

                    );
                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
 public EFItemRepository(ApplicationDBContent ctx)
 {
     context = ctx;
 }