Example #1
0
        public static void FillCardHoldersWithFakeData(AtmEntities dbContext, CardHolderRepository userRepo)
        {
            dbContext.Configuration.AutoDetectChangesEnabled = false;
            dbContext.Configuration.ValidateOnSaveEnabled = false;
            var randomDataProvider = new RandomDataProvider();

            int length = FakeDataCount - userRepo.GetAll().Count();
            for (int i = 0; i < length; i++)
            {
                var currentCardHolder = new CardHolder()
                {
                    Name = randomDataProvider.GetFirstName() + " " + randomDataProvider.GetStringExact(1, RandomDataType.BigLetters) + " " + randomDataProvider.GetLastName()
                };

                userRepo.Insert(currentCardHolder);

                if (i % 133 == 0) // Randomly chosen value
                {
                    dbContext.SaveChanges();
                }
            }

            dbContext.Configuration.AutoDetectChangesEnabled = true;
            dbContext.Configuration.ValidateOnSaveEnabled = true;
        }