public static void EnsureSeedDatForContext(this AlumnoInfoDbContext context) { if (context.Alumnos.Any()) { return; } var alumnos = new List <Alumno>() { new Alumno() { Nombre = "Luis Angel", Email = "*****@*****.**", Telefono = "7331872838", FechaNacimiento = new DateTime(1997, 01, 17), Redes = new List <RedSocials> { new RedSocials() { Nombre = "Facebook", RedSocial = "www.facebook.com/Luisito" }, new RedSocials() { Nombre = "Twitter", RedSocial = "www.twitter.com/Luisito" } } }, new Alumno() { Nombre = "Pedro", Email = "*****@*****.**", Telefono = "7331171852", FechaNacimiento = new DateTime(1997, 03, 09), Redes = new List <RedSocials> { new RedSocials() { Nombre = "Facebook", RedSocial = "www.facebook.com/Pedro" } } } }; context.Alumnos.AddRange(alumnos); context.SaveChanges(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, AlumnoInfoDbContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } context.EnsureSeedDatForContext(); app.UseStatusCodePages(); AutoMapper.Mapper.Initialize(cfg => { //Mapear Entidad Alumno a Dto Alumno cfg.CreateMap <Entities.Alumno, Models.AlumnoWithoutRedSocialDto>(); cfg.CreateMap <Entities.Alumno, Models.AlumnoDto>(); cfg.CreateMap <Entities.RedSocials, Models.RedSocialDto>(); //Crear Punto de Interes cfg.CreateMap <Models.RedSocialForCreation, Entities.RedSocials>(); //Actualizacion completa de un punto de interes cfg.CreateMap <Models.RedSocialForUpdate, Entities.RedSocials>(); //Actualizacion Parcial cfg.CreateMap <Entities.RedSocials, Models.RedSocialForCreation>(); }); app.UseMvc(); //app.Run(async (context) => //{ // await context.Response.WriteAsync("Hello World!"); //}); }
public AlumnoInfoRepository(AlumnoInfoDbContext context) { _context = context; }
public DummyController(AlumnoInfoDbContext ctx) { _ctx = ctx; }