Example #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, SistemaAcademicoContext 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?}");
            });

            //inicializa la base
            DbInitializer.Initialier(context);
        }
        public static void Initialier(SistemaAcademicoContext context)
        {
            context.Database.EnsureCreated();
            //cre la base de datos

            //buscar si existen registros  en la tabla categoria

            if (context.Categoria.Any())  //si hay categorias solo retorna eso y ya
            {
                return;
            }
            var categorias = new Categoria[]
            {
                new Categoria {
                    Nombre = "Programación", Descripcion = "Cursos de Asp.-net", Estado = true
                },
                new Categoria {
                    Nombre = "Diseño", Descripcion = "Diseño grafico", Estado = true
                },
                new Categoria {
                    Nombre = "Reparación ", Descripcion = "Reparacion de celulares", Estado = true
                }
            };

            foreach (Categoria c in categorias)
            {
                context.Categoria.Add(c);
            }
            context.SaveChanges();
        }
Example #3
0
        public static void Initialize(SistemaAcademicoContext context)
        {
            context.Database.EnsureCreated(); //Se crea la base dedatos

            //Buscar si existen registros en la tabla Categoria
            if (context.Categoria.Any())
            {
                return;
            }
            var categorias = new Categoria[]
            {
                new Categoria {
                    Nombre = "Programación", Descripcion = "Curso de Programación", Estado = true
                },
                new Categoria {
                    Nombre = "Diseño gráfico", Descripcion = "Curso de diseño gráfico", Estado = true
                }
            };

            foreach (Categoria categoria in categorias)
            {
                context.Categoria.Add(categoria);
            }

            context.SaveChanges();
        }
Example #4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, SistemaAcademicoContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
            DBInitializer.Initialize(context);
        }
Example #5
0
        private readonly SistemaAcademicoContext _context;//contecto de datos

        public CategoriasController(SistemaAcademicoContext context)
        {
            _context = context;
        }
Example #6
0
 public EstudiantesController(SistemaAcademicoContext context)
 {
     _context = context;
 }
Example #7
0
 public CarrerasController(SistemaAcademicoContext context)
 {
     _context = context;
 }