Beispiel #1
0
 public static void InitDb(CinemaBoxDb db)
 {
     if (!db.MovieShows.Any())
     {
         var movieShows = Enumerable.Range(1, 10).Select(i =>
                                                         new MovieShow
         {
             BeginTime = DateTime.Now,
             Name      = $"Киносеанс с фильмом № {i}",
         }).ToArray();
         db.MovieShows.AddRange(movieShows);
         db.SaveChanges();
         if (!db.Orders.Any())
         {
             var orders = Enumerable.Range(1, 20).Select(i =>
                                                         new Order
             {
                 DateTime  = DateTime.Now.AddHours(-2),
                 Count     = rnd.Next(1, 5),
                 MovieShow = movieShows[rnd.Next(movieShows.Length)],
             }).ToArray();
             db.Orders.AddRange(orders);
             db.SaveChanges();
         }
     }
 }
 public MovieShowRepository(CinemaBoxDb db)
 {
     _db = db;
 }
 public OrdersReporitory(CinemaBoxDb db)
 {
     _db = db;
 }