chore: rework dbinit slightly
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
* fill the tables only if there's nothing in them already
This commit is contained in:
parent
0779d07d84
commit
8dda15cfac
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using pwt_0x01_ng.Models.Database;
|
||||
using System.Collections.Generic;
|
||||
using pwt_0x01_ng.Models;
|
||||
|
@ -10,15 +11,16 @@ namespace pwt_0x01_ng.Models.Database
|
|||
|
||||
public static void Init(DBContext dbContext)
|
||||
{
|
||||
if (dbContext.Database.EnsureCreated())
|
||||
{
|
||||
dbContext.Database.EnsureCreated();
|
||||
if(dbContext.Carousel.Count() == 0){
|
||||
IList<Carousel> carousels = CarouselHelper.GenerateCarousel();
|
||||
foreach (var c in carousels)
|
||||
{
|
||||
dbContext.Carousel.Add(c);
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
|
||||
}
|
||||
if(dbContext.Product.Count() == 0){
|
||||
IList<Product> products = ProductHelper.GenerateProduct();
|
||||
foreach (var p in products)
|
||||
{
|
||||
|
|
Reference in New Issue