public void Equals_ShouldReturnFalse_DifferentIds()
        {
            var date   = DateTime.Now;
            var model1 = new MigrationModel("name1", date, 2);
            var model2 = new MigrationModel("name1", date, 3);

            model1.Should().NotBeEquivalentTo(model2);
        }
 public FileMigrationHandler(ObservableCollection <FileToBeMigrated> filesToWorkWith, MigrationModel migrationModel,
                             string preferredKeywordDelimiter, string keywordCategoryName)
 {
     FilesNotUploaded             = filesToWorkWith;
     Migration                    = migrationModel;
     KeywordDelimiter             = preferredKeywordDelimiter;
     PreferredKeywordCategoryname = keywordCategoryName;
 }
        public void Equals_ShouldReturnTrue_ReferenceTheSame()
        {
            var date   = DateTime.Now;
            var model1 = new MigrationModel("name1", date, 2);
            var model2 = model1;

            model1.Should().BeEquivalentTo(model2);
        }
        public void Equals_ShouldReturnTrue_AllFieldsAreEqual()
        {
            var date   = DateTime.Now;
            var model1 = new MigrationModel("name1", date, 2);
            var model2 = new MigrationModel("name1", date, 2);

            model1.Should().BeEquivalentTo(model2);
        }
예제 #5
0
        public async Task <IActionResult> Migrate([FromBody] MigrationModel model)
        {
            if (model.Membership == null)
            {
                throw ErtisAuthException.ValidationError(new[] { "membership is required" });
            }

            if (model.User == null)
            {
                throw ErtisAuthException.ValidationError(new[] { "user is required" });
            }

            if (!this.Request.Headers.ContainsKey("ConnectionString"))
            {
                throw ErtisAuthException.ValidationError(new[] { "ConnectionString must be post in header" });
            }

            var connectionString = this.Request.Headers["ConnectionString"];

            var membership = new Membership
            {
                Name                  = model.Membership.Name,
                ExpiresIn             = model.Membership.ExpiresIn,
                RefreshTokenExpiresIn = model.Membership.RefreshTokenExpiresIn,
                HashAlgorithm         = model.Membership.HashAlgorithm,
                DefaultEncoding       = model.Membership.DefaultEncoding,
                SecretKey             = model.Membership.SecretKey,
            };

            var user = new UserWithPasswordHash
            {
                Username     = model.User.Username,
                EmailAddress = model.User.EmailAddress,
                FirstName    = model.User.FirstName,
                LastName     = model.User.LastName,
                PasswordHash = model.User.Password,
                Role         = model.User.Role,
                Forbidden    = model.User.Forbidden,
                Permissions  = model.User.Permissions
            };

            Application application = null;

            if (model.Application != null)
            {
                application = new Application
                {
                    Name = model.Application.Name,
                    Role = model.Application.Role
                };
            }

            this.Request.HttpContext.Items.Add("SysUtilizer", "migration");

            var migrationResult = await this.migrationService.MigrateAsync(connectionString, membership, user, application);

            return(this.Ok(migrationResult));
        }
예제 #6
0
        public async Task <IActionResult> Migrate([FromBody] MigrationModel model)
        {
            if (model.Membership == null)
            {
                throw ErtisAuthException.ValidationError(new[] { "membership is required" });
            }

            if (model.User == null)
            {
                throw ErtisAuthException.ValidationError(new[] { "user is required" });
            }

            if (!this.Request.Headers.ContainsKey("ConnectionString"))
            {
                throw ErtisAuthException.ValidationError(new[] { "ConnectionString must be post in header" });
            }

            var connectionString = this.Request.Headers["ConnectionString"];

            var membership = new Membership
            {
                Name                  = model.Membership.Name,
                ExpiresIn             = model.Membership.ExpiresIn,
                RefreshTokenExpiresIn = model.Membership.RefreshTokenExpiresIn,
                HashAlgorithm         = model.Membership.HashAlgorithm,
                DefaultEncoding       = model.Membership.DefaultEncoding,
                SecretKey             = model.Membership.SecretKey
            };

            var user = new UserWithPassword
            {
                Username     = model.User.Username,
                EmailAddress = model.User.EmailAddress,
                FirstName    = model.User.FirstName,
                LastName     = model.User.LastName,
                PasswordHash = model.User.Password
            };

            var migrationResult = await this.migrationService.MigrateAsync(connectionString, membership, user);

            return(this.Ok(migrationResult));
        }
예제 #7
0
        public ShellViewModel(IMigrationService migrationService)
        {
            this.SetInactive();

            this.migrationService = migrationService;

            this.Migrations = new ObservableCollection <RecognizedMigrationFile>();
            this.seeders    = new ObservableCollection <RecognizedMigrationFile>();

            this.RestoreConnectionStrings();

            this.ProviderNames = new List <string>
            {
                "System.Data.SqlClient",
                "MySql.Data.MySqlClient"
            };

            this.model = new MigrationModel
            {
                ProviderName   = this.ProviderNames[0],
                ValidationMode = ValidationMode.Submit
            };

            this.InitAssemblyCommand();

            this.InitUpAllCommand();
            this.InitDownAllCommand();
            this.InitUpOneCommand();
            this.InitDownOneCommand();

            this.InitSeedAllCommand();
            this.InitSeedOneCommand();

            this.InitGenMigrationScriptCommand();
            this.InitGenSeedScriptCommand();
        }