Beispiel #1
0
        public override void AfterDatabaseInitialized()
        {
            base.AfterDatabaseInitialized();

            var dbc    = AppConfig.DatabaseCreation;
            var colors = ColorDataProvider.GetList().ToArray();
            var models = BikeModelDataProvider.GetList().ToArray();
            var user   = UserDataProvider.GetByUserName(dbc.AdminUserEmail, true);

            for (int i = 0; i < dbc.TestBikesCount; i++)
            {
                var available = ThreadSafeRandom.NextBool();

                BikeDataProvider.Add(new Bike(
                                         0,
                                         available ? BikeState.Available: ThreadSafeRandom.NextItem(new[] {
                    BikeState.Reserved,
                    BikeState.Reserved,
                    BikeState.Reserved,
                    BikeState.Reserved,
                    BikeState.Reserved,
                    BikeState.Reserved,
                    BikeState.Reserved,
                    BikeState.Reserved,
                    BikeState.Lost,
                    BikeState.Maintenance
                }),
                                         ThreadSafeRandom.NextItem(models),
                                         ThreadSafeRandom.NextItem(colors),
                                         // put around Érd?
                                         ThreadSafeRandom.Next(10) == 0 ?
                                         new Location(Hungary_Pest_Erd.Lat + ThreadSafeRandom.NextDouble(-1d, 1d), Hungary_Pest_Erd.Lng + ThreadSafeRandom.NextDouble(-1d, 1d), true) :
                                         new Location(ThreadSafeRandom.NextDouble(-90d, 90d), ThreadSafeRandom.NextDouble(-180d, 180d), true)
                                         ,
                                         ThreadSafeRandom.NextItem(new[] {
                    "San Francisco", "New York", "Paris", "Budapest", "Berlin", "Tokyo", "Washington", "Dallas", "Houston", "London", "Madrid", "Rome", "Lisbon", "Vien", "Beijing",
                    "Melbourne", "Sydney", "Rio", "Amsterdam", "Gant", "Brussels", "Moscow", "Delhi", "Genova", "Ottawa", "Mexico City", "Los Angeles", "Las Vegas"
                }),
                                         DateTime.UtcNow.AddMinutes(available ? ThreadSafeRandom.Next(-30 * 24 * 60, 0) : ThreadSafeRandom.Next(1, 5 * 24 * 60)),
                                         (float)ThreadSafeRandom.NextDouble(0d, 5d),
                                         DateTime.UtcNow,
                                         user,
                                         null,
                                         null,
                                         false
                                         ));
            }
        }
Beispiel #2
0
 /// <summary>
 /// Case sensitive, accent sensitive to use UserNameIndex
 /// </summary>
 protected User GetByUserName(string userName, bool?isActive)
 {
     return(UserDataProvider.GetByUserName(userName, isActive));
 }