// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, GratifyDbContext gratifyDbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseHttpStatusCodeExceptionMiddleware(); } else { app.UseHttpStatusCodeExceptionMiddleware(); app.UseExceptionHandler(); } AutoMapper.Mapper.Initialize(cfg => { // cfg.CreateMap<Entities.City, Models.CityWithoutPointsOfInterestDto>(); }); app.UseMvc(); //Creates Database gratifyDbContext.Database.EnsureCreated(); //Seeds Test Data gratifyDbContext.EnsureSeedDataForContext(); }
public UserRepository(GratifyDbContext dbContext) { _dbContext = dbContext; }
public WishListRepository(GratifyDbContext dbContext) { _dbContext = dbContext; }
public static void EnsureSeedDataForContext(this GratifyDbContext context) { if (context.WishLists.Any()) { return; } // init seed data var wishLists = new List <WishList>() { new WishList() { Name = "Teste WishList", Description = "List to test functionalities", Items = new List <Item>() { new Item() { Name = "Secador de Cabelo", URL = "https://www.americanas.com.br/produto/132532746", Price = 23.12 }, new Item() { Name = "Grampeador", URL = "https://www.americanas.com.br/produto/132532746" }, }, Owner = new User() { Name = "Test User", Email = "*****@*****.**", Bio = "Olá usuário de teste 1", UserName = "******" } }, new WishList() { Name = "Lista Da Val", Description = "Lista para meu aniversário", Items = new List <Item>() { new Item() { Name = "Shampoo", URL = "https://www.americanas.com.br/produto/132532746", }, new Item() { Name = "Mouse", URL = "https://www.americanas.com.br/produto/132532746", Price = 10.62 }, }, Owner = new User() { Name = "Usuario 2", Email = "*****@*****.**", Bio = "Olá usuário de usuario2", UserName = "******" } }, new WishList() { Name = "Casamento João e Ricardo", Description = "Lista do meu casamento", Items = new List <Item>() { new Item() { Name = "Monitor", URL = "https://www.americanas.com.br/produto/132532746" }, new Item() { Name = "Bicicleta", URL = "https://www.americanas.com.br/produto/132532746", Price = 1900.62 }, }, Owner = new User() { Name = "Joao", Email = "*****@*****.**", Bio = "Olá biografia de joao", UserName = "******" } } }; context.WishLists.AddRange(wishLists); context.SaveChanges(); //executes statements }
public ItemRepository(GratifyDbContext dbContext) { _dbContext = dbContext; }