Exemple #1
0
        public DataBaseSeeder SeedInitial()
        {
            BulkCopyOptions options = new BulkCopyOptions
            {
                CheckConstraints = false,
                BulkCopyType     = BulkCopyType.Default,
                KeepIdentity     = true
            };

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Data seed Initial in DataBase:");
            Console.ResetColor();

            Console.WriteLine("SectionTypes");
            db.BulkCopy(options, dataContainer.SectionTypes);

            Console.WriteLine("Categories");
            db.BulkCopy(options, dataContainer.Categories);

            Console.WriteLine("Users");
            db.BulkCopy(options, dataContainer.Users);

            Console.WriteLine("Roles");
            db.BulkCopy(options, dataContainer.Roles);

            Console.WriteLine("UserRoles");
            db.BulkCopy(options, dataContainer.UserRoles);

            Console.WriteLine("OperationKeys");
            db.BulkCopy(options, dataContainer.OperationKeys);

            Console.WriteLine("CategoryAccesses");
            db.BulkCopy(options, dataContainer.CategoryAccesses);

            Console.WriteLine("CategoryOperationAccesses");
            db.BulkCopy(options, dataContainer.CategoryOperationAccesses);

            RunDbCpecificCode();

            return(this);
        }
        private static void EnsureItems(DataBaseConnection db)
        {
            var allItemsDic = db.ConfigurationItems.ToList().ToDictionary(x => x.Name, x => x);
            var itemsToAdd  = new List <ConfigurationItem>();

            foreach (var(name, value) in ConfigDefaults.ConfigurationItems)
            {
                if (!allItemsDic.ContainsKey(name))
                {
                    itemsToAdd.Add(
                        new ConfigurationItem
                    {
                        Name  = name,
                        Value = value.ToString()
                    }
                        );
                }
            }

            db.BulkCopy(itemsToAdd);
        }
        public DataBaseSeeder SeedInitial()
        {
            BulkCopyOptions options = new BulkCopyOptions
            {
                CheckConstraints = false,
                BulkCopyType     = BulkCopyType.Default,
                KeepIdentity     = true
            };

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Data seed Initial in DataBase:");
            Console.ResetColor();

            Console.WriteLine("Categories");
            db.BulkCopy(options, dataContainer.Categories);

            Console.WriteLine("Users");
            db.BulkCopy(options, dataContainer.Users);

            Console.WriteLine("Materials");
            db.BulkCopy(options, dataContainer.Materials);

            Console.WriteLine("Roles");
            db.BulkCopy(options, dataContainer.Roles);

            Console.WriteLine("UserRoles");
            db.BulkCopy(options, dataContainer.UserRoles);

            Console.WriteLine("OperationKeys");
            db.BulkCopy(options, dataContainer.OperationKeys);

            Console.WriteLine("CategoryAccesses");
            db.BulkCopy(options, dataContainer.CategoryAccesses);

            Console.WriteLine("CategoryOperationAccesses");
            db.BulkCopy(options, dataContainer.CategoryOperationAccesses);

            Console.WriteLine("MenuItems");
            db.BulkCopy(options, dataContainer.MenuItems);

            Console.WriteLine("Components");
            db.BulkCopy(options, dataContainer.Components);

            Console.WriteLine("CipherSecrets");
            db.BulkCopy(options, dataContainer.CipherSecrets);


            if (dataContainer.CacheSettings != null)
            {
                Console.WriteLine("Cache Settings");
                db.Insert(dataContainer.CacheSettings);
            }

            RunDbCpecificCode();

            return(this);
        }