public void RegenerateViewModels(AzureEventLogReader logReader, string dbConnectionString) { var commandBus = new NullCommandBus(); Database.SetInitializer <ConferenceRegistrationDbContext>(null); var handlers = new List <IEventHandler>(); handlers.Add(new ConferenceViewModelGenerator(() => new ConferenceRegistrationDbContext(dbConnectionString), commandBus)); handlers.Add(new PricedOrderViewModelUpdater(() => new ConferenceRegistrationDbContext(dbConnectionString))); using (var context = new ConferenceRegistrationMigrationDbContext(dbConnectionString)) { context.UpdateTables(); } try { var dispatcher = new EventDispatcher(handlers); var events = logReader.Query(new QueryCriteria { }); dispatcher.DispatchMessages(events); } catch { using (var context = new ConferenceRegistrationMigrationDbContext(dbConnectionString)) { context.RollbackTablesMigration(); } throw; } }
public void RegenerateViewModels(AzureEventLogReader logReader, string dbConnectionString) { var commandBus = new NullCommandBus(); Database.SetInitializer<ConferenceRegistrationDbContext>(null); var handlers = new List<IEventHandler>(); handlers.Add(new ConferenceViewModelGenerator(() => new ConferenceRegistrationDbContext(dbConnectionString), commandBus)); handlers.Add(new PricedOrderViewModelUpdater(() => new ConferenceRegistrationDbContext(dbConnectionString))); using (var context = new ConferenceRegistrationMigrationDbContext(dbConnectionString)) { context.UpdateTables(); } try { var dispatcher = new MessageDispatcher(handlers); var events = logReader.Query(new QueryCriteria { }); dispatcher.DispatchMessages(events); } catch { using (var context = new ConferenceRegistrationMigrationDbContext(dbConnectionString)) { context.RollbackTablesMigration(); } throw; } }