public async Task InitializeAsync(EventsContext eventsContext) { await eventsContext.Database.EnsureCreatedAsync(); if (!await eventsContext.Events.AnyAsync()) { await eventsContext.Events.AddRangeAsync( new List <Event>() { new Event { EventKey = "GeneralConferenceAlpha", StartTime = DateTime.Today, EndTime = DateTime.Today.AddDays(5d), Title = "First General Conference", Description = "Sed in euismod mi.", RegistrationCount = 15 }, new Event { EventKey = "GeneralConferenceBravo", StartTime = DateTime.Today.AddDays(10d), EndTime = DateTime.Today.AddDays(15d), Title = "Second General Conference", Description = "Sed in euismod mi.", RegistrationCount = 20 }, new Event { EventKey = "GeneralConferenceCharlie", StartTime = DateTime.Today.AddDays(20d), EndTime = DateTime.Today.AddDays(25d), Title = "Third General Conference", Description = "Sed in euismod mi.", RegistrationCount = 5 }, new Event { EventKey = "GeneralConferenceDelta", StartTime = DateTime.Today.AddDays(30d), EndTime = DateTime.Today.AddDays(35d), Title = "Fourth General Conference", Description = "Sed in euismod mi.", RegistrationCount = 25 }, new Event { EventKey = "GeneralConferenceEcho", StartTime = DateTime.Today.AddDays(40d), EndTime = DateTime.Today.AddDays(45d), Title = "Fifth General Conference", Description = "Sed in euismod mi.", RegistrationCount = 10 }, new Event { EventKey = "GeneralConferenceFoxtrot", StartTime = DateTime.Today.AddDays(50d), EndTime = DateTime.Today.AddDays(55d), Title = "Sixth General Conference", Description = "Sed in euismod mi.", RegistrationCount = 0 } } ); await eventsContext.SaveChangesAsync(); } }
public async Task InitializeAsync(EventsContext eventsContext, RegistrationContext registrationContext) { await eventsContext.Database.EnsureCreatedAsync(); await registrationContext.ConfigureConnectionAsync(); List <Event> events = new List <Event>(); if (await eventsContext.Events.AnyAsync()) { events = await eventsContext.Events.ToListAsync(); } else { events = GenerateEvents(); await eventsContext.Events.AddRangeAsync(events); await eventsContext.SaveChangesAsync(); } if (await registrationContext.GetRegistrantCountAsync() == 0) { List <GeneralRegistration> registrations = GenerateRegistrants(events); foreach (var registrant in registrations) { await registrationContext.UploadEventRegistrationAsync(registrant); } } }
public async Task InitializeAsync(EventsContext eventsContext) { await eventsContext.Database.EnsureCreatedAsync(); List <Event> events = new List <Event>(); if (await eventsContext.Events.AnyAsync()) { events = await eventsContext.Events.ToListAsync(); } else { events = GenerateEvents(); await eventsContext.Events.AddRangeAsync(events); await eventsContext.SaveChangesAsync(); } }