public SettingsController(HeroesContext heroesContext, IAllHeroes iAllHeroes, IHeroesAtribute iHeroesAtribute, IWebHostEnvironment appEnvironment) { _heroesContext = heroesContext; _appEnvironment = appEnvironment; AllHeroes = iAllHeroes; HeroesAtribute = iHeroesAtribute; }
public MainPresenter(IMainView mv) { db = new HeroesContext(); db.Heroes.Load(); heros = db.Heroes.Local.ToBindingList(); currentView = mv; mv.ClickButtonEvent += Mv_ClickButtonEvent; }
public Get() { var services = new ServiceCollection(); services.AddEntityFrameworkInMemoryDatabase() .AddDbContext<HeroesContext>(x => x.UseInMemoryDatabase().UseInternalServiceProvider(new ServiceCollection().AddEntityFrameworkInMemoryDatabase().BuildServiceProvider())); // Don't share context data -> use new InternalServiceProvider per instance _context = services.BuildServiceProvider().GetRequiredService<HeroesContext>(); _controller = new HeroesController(_context); }
public static void Initial(HeroesContext content) { if (!content.Atribute.Any()) { content.Atribute.AddRange( new Atribute { AtributeName = "Agility", decs = "Ловкач получает броню,скорость атаки и урон за каждую единицу", }, new Atribute { AtributeName = "Strengh", decs = "Силовик, Получает здоровье и урон за каждую единицу", }, new Atribute { AtributeName = "Intelligence", decs = "Интовик получает ману, урон и урон от способностей за каждую единицу", } ); content.SaveChanges(); } if (!content.Atribute.Any()) { content.Atribute.AddRange( new Atribute { AtributeName = "Agility", decs = "Ловкач получает броню,скорость атаки и урон за каждую единицу", }, new Atribute { AtributeName = "Strengh", decs = "Силовик, Получает здоровье и урон за каждую единицу", }, new Atribute { AtributeName = "Intelligence", decs = "Интовик получает ману, урон и урон от способностей за каждую единицу", } ); content.SaveChanges(); } if (!content.Heroes.Any()) { content.Heroes.AddRange( new Hero { Name = "Slark", decs = "Ловкач Ескейпер", img = "/img/slark_icon.png", Atribute = content.Atribute.First(x => x.AtributeName == "Agility") }, new Hero { Name = "Io", decs = "Силовик хиллер", img = "/img/io_icon.png", Atribute = content.Atribute.First(x => x.AtributeName == "Strengh") }, new Hero { Name = "Lina", decs = "Интовик DMGДиллер", img = "/img/Lina_icon.png", Atribute = content.Atribute.First(x => x.AtributeName == "Intelligence") }); content.SaveChanges(); } if (!content.Items.Any()) { content.Items.Add(new Items { First_item = "ao", Second_item = "ad", Third_item = "nana", Forth_item = "nono", Fifth_item = "5", Sixth_item = "6", Heroes = content.Heroes.First(x => x.Name == "Slark") }); content.SaveChanges(); } content.SaveChanges(); }
public Get() { var services = new ServiceCollection(); services.AddEntityFrameworkInMemoryDatabase() .AddDbContext <HeroesContext>(x => x.UseInMemoryDatabase().UseInternalServiceProvider(new ServiceCollection().AddEntityFrameworkInMemoryDatabase().BuildServiceProvider())); // Don't share context data -> use new InternalServiceProvider per instance _context = services.BuildServiceProvider().GetRequiredService <HeroesContext>(); _controller = new HeroesController(_context); }
private void InitializeTestServer() { var config = new ConfigurationBuilder() .SetBasePath(AppContext.BaseDirectory) .AddJsonFile("appsettings.json", false, true) .AddEnvironmentVariables() .Build(); var optionsBuilder = new DbContextOptionsBuilder <HeroesContext>(); optionsBuilder.UseSqlServer(config["ConnectionStrings:heroesConnection"]); DbContext = new HeroesContext(optionsBuilder.Options); DbContext.Database.Migrate(); }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new HeroesContext( serviceProvider.GetRequiredService <DbContextOptions <HeroesContext> >())) { var first = 1; if (context.Heroes.Find((long)first) != null) { return; // DB has been seeded } context.Heroes.AddRange( new Hero { //Id = 11, Name = "Superman" }, new Hero { //Id = 12, Name = "Batman" }, new Hero { //Id = 13, Name = "Spiderman" }, new Hero { //Id = 14, Name = "Deathpool" }, new Hero { //Id = 15, Name = "Wonderwoman" } ); context.SaveChanges(); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseSession(); // добавляем механизм работы с сессиями app.UseDeveloperExceptionPage(); app.UseRouting(); app.UseAuthentication(); // аутентификация app.UseAuthorization(); // авторизация app.UseStaticFiles(); app.UseStatusCodePages(); app.UseMvc(routes => { routes.MapRoute("View", "{controller=Heroes}/{action=List}"); }); using (var scope = app.ApplicationServices.CreateScope()) { HeroesContext content = scope.ServiceProvider.GetRequiredService <HeroesContext>(); DbObjects.Initial(content); } }
public AccountController(HeroesContext context) { _context = context; }
public HeroesController(HeroesContext context) { _context = context; }
public HeroesController(HeroesContext todoContext) { _context = todoContext; }
public AtributeRepository(HeroesContext heroesContext) { this.heroesContext = heroesContext; }
public HeroRepository(HeroesContext heroesContext) { this.heroesContext = heroesContext; }
public Repository() { _context = new HeroesContext(); _context.Configuration.LazyLoadingEnabled = false; }
public PlanetsController(HeroesContext context) { _context = context; }
public Repository(HeroesContext context) { this.context = context; this.dbSet = context.Set <TEntity>(); }
public CategoriasController(HeroesContext context) { _context = context; }
public HeroesController(HeroesContext context, ILogger <HeroesController> logger) { this.context = context; this.logger = logger; }
public HeroesController(HeroesContext heroesContext) { HeroesContext = heroesContext; }
public HeroesRepository(HeroesContext context) { _context = context; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, HeroesContext context) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true }); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routes.MapSpaFallbackRoute( name: "spa-fallback", defaults: new { controller = "Home", action = "Index" }); }); HeroDbInitializer.Initialize(context); }