Example #1
0
        public static void Initialize(ProgramaAcademicoContext context)
        {
            context.Database.EnsureCreated();

            //Buscar si existen registros en la tabla categoría
            if (context.Categoria.Any())
            {
                return;
            }
            else
            {
                var categorias = new Categoria[]
                {
                    new Categoria {
                        Nombres = "Alan Jackson", Apellidos = "Duarte Marroquín", Descripcion = "The Father", Estado = true
                    },
                    new Categoria {
                        Nombres = "Denise Asunción", Apellidos = "Duarte Castro", Descripcion = "The daugther", Estado = true
                    }
                };

                foreach (Categoria c in categorias)
                {
                    context.Categoria.Add(c);
                }
                context.SaveChanges();
            }
        }
Example #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, ProgramaAcademicoContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

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

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
            DbInitializer.Initialize(context);
        }
Example #3
0
 public CategoriasController(ProgramaAcademicoContext context)
 {
     _context = context;
 }