示例#1
0
        public static void Initialize(EshopDBContext dBContext)
        {
            dBContext.Database.EnsureCreated();

            if (dBContext.Carousels.Count() == 0)
            {
                IList <Carousel> carousels = CarouselHelper.GenerateCarousel();
                foreach (var item in carousels)
                {
                    dBContext.Carousels.Add(item);
                }

                dBContext.SaveChanges();
            }

            if (dBContext.Products.Count() == 0)
            {
                IList <Product> products = ProductsHelper.GenerateProducts();
                foreach (var item in products)
                {
                    dBContext.Products.Add(item);
                }
                dBContext.SaveChanges();
            }
        }
示例#2
0
 static DatabaseFake()
 {
     Carousels = CarouselHelper.GenerateCarousel();
     Products  = ProductsHelper.GenerateProducts();
 }