public static void Initialize(IServiceProvider serviceProvider) { using (var context = new CMSShoppingCartContext(serviceProvider.GetRequiredService <DbContextOptions <CMSShoppingCartContext> >())) { if (context.Pages.Any()) { return; } context.Pages.AddRange( new Page { Title = "Home", Slug = "home", Content = "home page", Sorting = 0, }, new Page { Title = "About Us", Slug = "about-us", Content = "about us page", Sorting = 1, }, new Page { Title = "Services", Slug = "services", Content = "services page", Sorting = 2, }, new Page { Title = "Contact", Slug = "contact", Content = "contact page", Sorting = 3, } ); context.SaveChanges(); } }
public ProductsController(CMSShoppingCartContext context, IWebHostEnvironment webHostEnvironment) { this.context = context; this.webHostEnvironment = webHostEnvironment; }
public PagesController(CMSShoppingCartContext context) { this.context = context; }
public CategoriesController(CMSShoppingCartContext context) { this.context = context; }