Exemple #1
0
        private void initializeDabases(IApplicationBuilder app)
        {
            createSqliteDbFile();

            // In-case that we need to do some migrations.
            using (var scope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
            {
                ApplicationDbContext applicationDbContext = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>();
                if (applicationDbContext.Database.GetPendingMigrations().Any())
                {
                    applicationDbContext.Database.Migrate();
                }
                EventyDbContext eventyDbContext = scope.ServiceProvider.GetRequiredService <EventyDbContext>();
                if (eventyDbContext.Database.GetPendingMigrations().Any())
                {
                    eventyDbContext.Database.Migrate();
                }
                SeedData.Initialize(scope.ServiceProvider.GetRequiredService <IServiceProvider>());
            }
        }
Exemple #2
0
        private static void seedFamilyMembers(EventyDbContext eventyDbContext)
        {
            if (eventyDbContext.FamilyMembers.Any())
            {
                return;
            }

            if (!File.Exists(@"Seeds/familymembers.json"))
            {
                return;
            }

            if (!eventyDbContext.FamilyMembers.Any())
            {
                Console.WriteLine("Seeding family members...");

                var familyMembers = JsonConvert.DeserializeObject <List <FamilyMember> >(
                    File.ReadAllText(@"Seeds/familymembers.json")
                    );

                eventyDbContext.FamilyMembers.AddRange(familyMembers);
                eventyDbContext.SaveChanges();
            }
        }
Exemple #3
0
        private static void seedEventsFamilies(EventyDbContext eventyDbContext)
        {
            if (eventyDbContext.EventsFamilies.Any())
            {
                return;
            }

            if (!File.Exists(@"Seeds/eventsfamilies.json"))
            {
                return;
            }

            if (!eventyDbContext.EventsFamilies.Any())
            {
                Console.WriteLine("Seeding eventsfamilies...");

                var eventsFamilies = JsonConvert.DeserializeObject <List <EventsFamilies> >(
                    File.ReadAllText(@"Seeds/eventsfamilies.json")
                    );

                eventyDbContext.EventsFamilies.AddRange(eventsFamilies);
                eventyDbContext.SaveChanges();
            }
        }
Exemple #4
0
 public FamiliesRepository(EventyDbContext eventyDbContext)
 {
     EventyDbContext = eventyDbContext;
 }
Exemple #5
0
 public FamilyMemberController(EventyDbContext context)
 {
     _context = context;
 }
 public EventsFamilyMembersController(EventyDbContext context)
 {
     Context = context;
 }
Exemple #7
0
 public EventController(EventyDbContext context)
 {
     _context = context;
 }