Exemple #1
0
        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();
            }
        }
Exemple #2
0
 public ProductsController(CMSShoppingCartContext context, IWebHostEnvironment webHostEnvironment)
 {
     this.context            = context;
     this.webHostEnvironment = webHostEnvironment;
 }
Exemple #3
0
 public PagesController(CMSShoppingCartContext context)
 {
     this.context = context;
 }
 public CategoriesController(CMSShoppingCartContext context)
 {
     this.context = context;
 }