internal void GenerateRandomPeopleData(string dbName, string host, int numberOfEntities)
        {
            var dbController = new MongoDbController(dbName, host);
            var db = dbController.GetDatabase();
            var collection = db.GetCollection<PersonMongo>("Person");
            var personCollection = new List<PersonMongo>();
            var countryGenerator = new CountriesCollection();
            var randomGenerator = new RandomGenerator();

            for (int i = 1; i <= numberOfEntities; i++)
            {
                personCollection.Add(new PersonMongo(
                    i,
                    randomGenerator.GetRandomString(3, 5, true),
                    randomGenerator.GetRandomString(4, 7, true),
                    GetGender(i),
                    randomGenerator.GetRandomInt(1920,2015),
                    countryGenerator.GetRandomCountry()));
            }

            collection.InsertManyAsync(personCollection);
            Console.Write("Press key");
            Console.ReadKey();

            Console.WriteLine("Person data created");
        }
Esempio n. 2
0
        private static void AddToysToManufacturers(ToyStoreEntities db, RandomGenerator generator, IList<int> manufacturerIds, IList<Toy> toys)
        {
            var numberOfManufacturers = manufacturerIds.Count;
            Console.Write("Adding Toys to Manufacturers");

            var i = 0;
            foreach (var toy in toys)
            {
                toy.ManufacturerId = manufacturerIds[generator.GetRandomInt(0, numberOfManufacturers - 1)];
                db.SaveChanges();
                Printer.Print(20, numberOfManufacturers, i);
                i++;
            }
            Console.WriteLine();
        }
        public static int InserNewMovie()
        {
            var rand = new RandomGenerator();

            CinameNetworkEntities northwindEntities = new CinameNetworkEntities();

            Movy newProduct = new Movy
            {
                Title = rand.GetRandomString(5, 15),
                GenreId = rand.GetRandomInt(1, 1000),
                ReleaseDate = rand.GetRandomDateTime(),
                Director = rand.GetRandomInt(1, 1000),
                Actors = rand.GetRandomInt(1, 100),
                Description = rand.GetRandomString(20, 60),
                CoverLink = rand.GetRandomString(5, 25),
                Subtitles = false,
                DurationMinutes = rand.GetRandomInt(40, 150)
            };

            northwindEntities.Movies.Add(newProduct);
            northwindEntities.SaveChanges();

            return newProduct.MovieId;
        }