Ejemplo n.º 1
0
 public SettingsController(HeroesContext heroesContext, IAllHeroes iAllHeroes, IHeroesAtribute iHeroesAtribute, IWebHostEnvironment appEnvironment)
 {
     _heroesContext  = heroesContext;
     _appEnvironment = appEnvironment;
     AllHeroes       = iAllHeroes;
     HeroesAtribute  = iHeroesAtribute;
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 4
0
        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);
            }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 7
0
        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();
            }
        }
Ejemplo n.º 8
0
        // 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);
            }
        }
Ejemplo n.º 9
0
 public AccountController(HeroesContext context)
 {
     _context = context;
 }
 public HeroesController(HeroesContext context)
 {
     _context = context;
 }
Ejemplo n.º 11
0
 public HeroesController(HeroesContext todoContext)
 {
     _context = todoContext;
 }
Ejemplo n.º 12
0
 public AtributeRepository(HeroesContext heroesContext)
 {
     this.heroesContext = heroesContext;
 }
Ejemplo n.º 13
0
 public HeroesController(HeroesContext context)
 {
     _context = context;
 }
Ejemplo n.º 14
0
 public HeroRepository(HeroesContext heroesContext)
 {
     this.heroesContext = heroesContext;
 }
Ejemplo n.º 15
0
 public Repository()
 {
     _context = new HeroesContext();
     _context.Configuration.LazyLoadingEnabled = false;
 }
Ejemplo n.º 16
0
 public PlanetsController(HeroesContext context)
 {
     _context = context;
 }
Ejemplo n.º 17
0
 public Repository(HeroesContext context)
 {
     this.context = context;
     this.dbSet   = context.Set <TEntity>();
 }
Ejemplo n.º 18
0
 public CategoriasController(HeroesContext context)
 {
     _context = context;
 }
Ejemplo n.º 19
0
 public HeroesController(HeroesContext context, ILogger <HeroesController> logger)
 {
     this.context = context;
     this.logger  = logger;
 }
Ejemplo n.º 20
0
 public HeroesController(HeroesContext heroesContext)
 {
     HeroesContext = heroesContext;
 }
Ejemplo n.º 21
0
 public HeroesRepository(HeroesContext context)
 {
     _context = context;
 }
Ejemplo n.º 22
0
        // 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);
        }