public void TearDown()
 {
     //Clean up database
     _dbContext.Database.ExecuteSqlCommand("Delete AssociateAssociateTypes");
     _dbContext.Database.ExecuteSqlCommand("Delete AssociateTypes");
     _dbContext.Database.ExecuteSqlCommand("Delete Associates");
     _dbContext.SaveChanges();
     _dbContext.Dispose();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initialize default languages
        /// </summary>
        public void Initialize(DbContext ezContext)
        {
            var context = ezContext as EzCMSEntities;

            if (context != null)
            {
                #region Add countries

                if (!context.Countries.Any())
                {
                    var countryData = DataInitializeHelper.GetResourceContent("Country.Countries.txt",
                                                                              DataSetupResourceType.Others);
                    List <string> countryList =
                        countryData.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();

                    int i         = 0;
                    var countries = new List <Country>();
                    foreach (var item in countryList)
                    {
                        i = i + 1;
                        var country = new Country
                        {
                            Name        = item,
                            RecordOrder = i * 10
                        };

                        countries.Add(country);
                    }

                    var dbContext = new EzCMSEntities();
                    dbContext.Countries.AddIfNotExist(country => country.Name, countries.ToArray());
                    dbContext.SaveChanges();
                }

                #endregion

                #region Add Languages

                var languages = new[]
                {
                    new Language
                    {
                        Name        = "English",
                        Culture     = "United States",
                        Key         = "en-US",
                        IsDefault   = false,
                        RecordOrder = 20
                    }
                };
                context.Languages.AddIfNotExist(l => l.Name, languages);

                #endregion
            }
        }
Exemplo n.º 3
0
        protected override void Seed(EzCMSEntities context)
        {
            IEnumerable <IDataInitializer> initializers = Enumerable.Empty <IDataInitializer>();

            try
            {
                initializers = HostContainer.GetInstances <IDataInitializer>().OrderBy(i => i.Priority());
            }
            catch (Exception)
            {
                //Likely called from Package Manager Console
            }
            using (var scope = new TransactionScope())
            {
                foreach (var initializer in initializers)
                {
                    initializer.Initialize(context);
                    context.SaveChanges();
                }
                scope.Complete();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initialize default languages
        /// </summary>
        public void Initialize(DbContext ezContext)
        {
            var context = ezContext as EzCMSEntities;

            if (context != null)
            {
                var dbContext = new EzCMSEntities();

                var availableTools           = EnumUtilities.GetAllItems <EditorTool>().Select(t => t.ToString());
                var availableToolsJsonString = SerializeUtilities.Serialize(availableTools);
                var toolbar = new Toolbar
                {
                    Name         = "Default Toolbar",
                    IsDefault    = true,
                    BasicToolbar = availableToolsJsonString,
                    PageToolbar  = availableToolsJsonString
                };

                dbContext.Toolbars.AddIfConditionInvalid(t => t.IsDefault, toolbar);
                dbContext.SaveChanges();
            }
        }