Ejemplo n.º 1
0
        public static void Initialize(Academy_SystemContext context)
        {
            context.Database.EnsureCreated();

            //Search if exist register on table categories
            if (context.Categories.Any())
            {
                return;
            }

            var categories = new Categories[]
            {
                new Categories {
                    Name = "Programming", Description = "Courses of Programming", State = true
                },
                new Categories {
                    Name = "Design Graphic", Description = "Courses of Design Grafic", State = true
                }
            };

            foreach (Categories c in categories)
            {
                context.Categories.Add(c);
            }
            context.SaveChanges();
        }
Ejemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, Academy_SystemContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
            Initializerdb.Initialize(context);
        }
Ejemplo n.º 3
0
 public CategoriesController(Academy_SystemContext context)
 {
     _context = context;
 }