Beispiel #1
0
        public MigrationEntry BuildEntity(MigrationDto dto)
        {
            SemVersion parsed;

            if (SemVersion.TryParse(dto.Version, out parsed) == false)
            {
                throw new FormatException("Cannot parse the version string in the database to a SemVersion object: " + dto.Version);
            }

            var model = new MigrationEntry(dto.Id, dto.CreateDate, dto.Name, parsed);

            //on initial construction we don't want to have dirty properties tracked
            // http://issues.umbraco.org/issue/U4-1946
            model.ResetDirtyProperties(false);
            return(model);
        }
        /// <summary>
        /// Creates a migration entry, will throw an exception if it already exists
        /// </summary>
        /// <param name="migrationName"></param>
        /// <param name="version"></param>
        /// <returns></returns>
        public IMigrationEntry CreateEntry(string migrationName, SemVersion version)
        {
            var entry = new MigrationEntry
            {
                MigrationName = migrationName,
                Version       = version
            };

            using (var uow = UowProvider.GetUnitOfWork())
            {
                var repo = RepositoryFactory.CreateMigrationEntryRepository(uow);
                repo.AddOrUpdate(entry);
                uow.Commit();
            }

            return(entry);
        }