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"); }
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; }
public static void InsertNewCountries(int count) { while (count > 0) { var rand = new RandomGenerator(); CinameNetworkEntities northwindEntities = new CinameNetworkEntities(); Country newEntry = new Country { Name = rand.GetRandomString(5, 20) }; northwindEntities.Countries.Add(newEntry); northwindEntities.SaveChanges(); Console.WriteLine("Row affected - new country with movieId {0} created", newEntry.CountryId); count--; } }