public MigrationViewModel(ILog log, MigrationsViewModel migrationsVM, MigrationInfo migrationInfo) { _log = log; MigrationsVM = migrationsVM; MigrationInfo = migrationInfo; MigrationInfo.MigrationUpdated += async(s, e) => await Update(); IsInProgress = new Binding <bool>(); Description = new Binding <string>(); Version = new Binding <long>(); Tags = new ObservableCollection <TagViewModel>(); HasRun = new Binding <bool>(); IsToBeRun = new Binding <bool>(); IsSkipped = new Binding <bool>(); AppliedOn = new Binding <DateTime?>(); Sql = new Binding <string>(() => MigrationInfo.GetSqlAsync().Result); // TODO: Make nicer AddToDatabaseCommand = new RelayCommand(async param => await AddToDatabaseAsync(), param => !MigrationsVM.ProjectVM.IsReadOnly.Value); InitializeCommand = new RelayCommand(async param => await InitializeAsync()); MigrateDownCommand = new RelayCommand(async param => await MigrateDownAsync(), param => !MigrationsVM.ProjectVM.IsReadOnly.Value); MigrateToThisVersionCommand = new RelayCommand(async param => await MigrateToThisVersionAsync()); MigrateUpCommand = new RelayCommand(async param => await MigrateUpAsync(), param => !MigrationsVM.ProjectVM.IsReadOnly.Value); ReRunCommand = new RelayCommand(async param => await ReRunMigrateUpAsync(), param => !MigrationsVM.ProjectVM.IsReadOnly.Value); RemoveFromDatabaseCommand = new RelayCommand(async param => await RemoveFromDatabaseAsync(), param => !MigrationsVM.ProjectVM.IsReadOnly.Value); SaveToFileCommand = new RelayCommand(param => SaveToFile()); }
public ProjectViewModel(ILog log, RootViewModel root, ProjectConfiguration configProject) { _log = log; RootVM = root; DatabaseTypes = new ObservableCollection <DatabaseTypeViewModel>(DatabaseTypeViewModel.GetDatabaseTypes()); Id = configProject.Id; IsNew = new Binding <bool>(); IsInitialized = new Binding <bool>(); IsReadOnly = new Binding <bool>(configProject.IsReadOnly); IsLoadedOnStart = new Binding <bool>(configProject.IsLoadedOnStart); IsInProgress = new Binding <bool>(); IsNodeExpanded.Value = configProject.IsExpanded; PendingMigrationsCount = new Binding <int>(); HasPendingMigrations = new Binding <bool>(); MigrationsCount = new Binding <int>(); ProfilesCount = new Binding <int>(); Name = new Binding <string>(configProject.Name); ConnectionString = new Binding <string>(configProject.ConnectionString); PathToMigrationsFile = new Binding <string>(configProject.DllPath); DatabaseType = new Binding <DatabaseTypeViewModel>(); if (configProject.DatabaseType.HasValue) { DatabaseType.Value = DatabaseTypes.FirstOrDefault(d => d.Value == configProject.DatabaseType); } Tags = new Binding <string>(); if (configProject.Tags != null) { Tags.Value = string.Join(" ", configProject.Tags); } Profile = new Binding <string>(configProject.Profile); FullUpdateCommand = new RelayCommand(async param => await FullUpdateAsync(), param => !IsReadOnly.Value && IsInitialized.Value); MigrationsOnlyCommand = new RelayCommand(async param => await RunMigrationsAsync(), param => !IsReadOnly.Value && IsInitialized.Value); ProfilesOnlyCommand = new RelayCommand(async param => await RunProfilesAsync(), param => !IsReadOnly.Value && IsInitialized.Value); BrowsePathToMigrationsFileCommand = new RelayCommand(param => BrowsePathToMigrationsDll()); InitializeProjectCommand = new RelayCommand(async param => await InitializeAsync()); CloneProjectCommand = new RelayCommand(param => Clone()); RecreateDatabaseCommand = new RelayCommand(async param => await RecreateDatabaseAsync(), param => !IsReadOnly.Value && IsInitialized.Value); DeleteProjectCommand = new RelayCommand(async param => await DeleteAsync(), param => !IsReadOnly.Value); ProjectInfo = new ProjectInfo(null, null, null, RootVM.OutputVM); // Migrations MigrationsVM = new MigrationsViewModel(_log, this); MigrationsVM.IsNodeExpanded.Value = configProject.IsMigrationsExpanded; Add(MigrationsVM); // Profiles ProfilesVM = new ProfilesViewModel(_log, this); ProfilesVM.IsNodeExpanded.Value = configProject.IsProfilesExpanded; Add(ProfilesVM); }