示例#1
0
        private async Task <List <PokemonSkill> > GetPokemonSkills(int id, PokedexContext db)
        {
            var pokemonToPokemonSkillRepository = new PokemonToPokemonSkillRepository(db);
            var task = await pokemonToPokemonSkillRepository.GetByPokemonId(id);

            var results = task.Select(x => x.PokemonSkillId);

            var pokemonSkillRepository = new PokemonSkillRepository(db);
            var task2 = await pokemonSkillRepository.GetAll();

            return(task2.Where(x => results.Contains(x.Id)).ToList());
        }
示例#2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, PokedexContext context)
        {
            if (env.IsDevelopment())
            {
                context.Database.EnsureCreated();
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.ConfigureSwagger();

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseSpaStaticFiles();

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller}/{action=Index}/{id?}");
            });

            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseReactDevelopmentServer(npmScript: "start");
                }
            });

            app.UseStaticFiles(new StaticFileOptions
            {
                FileProvider = new PhysicalFileProvider(
                    Path.Combine(env.ContentRootPath, "ClientApp/Build")),
                RequestPath = "/www"
            });
        }
示例#3
0
 public PokemonController(PokedexContext db)
 {
     Db = db;
 }
示例#4
0
 public RegionesController(PokedexContext context)
 {
     _context = context;
 }
 public TypeRepository(PokedexContext context)
 {
     _context = context;
 }
示例#6
0
 public PokemonRepository(PokedexContext context)
 {
     _context = context;
 }
 public AccountController(PokedexContext context, SignInManager <User> signInManager)
 {
     _signInManager = signInManager;
     _context       = context;
 }
示例#8
0
 public TrainerRepository(PokedexContext pokedexContext)
 {
     _pokedexContext = pokedexContext;
 }
示例#9
0
 public HomeContentController(PokedexContext context)
 {
     _context = context;
 }
示例#10
0
 public PokemonFacade(PokedexContext _db)
 {
     Db = _db;
 }
示例#11
0
        public static async Task <bool> ProcessImages(ICollection <IFormFile> files, Pokemon pokemon, PokedexContext _context, IHostingEnvironment _environment, ModelStateDictionary m)
        {
            if (m.IsValid)
            {
                if (pokemon.ID == 0)
                {
                    List <HarvestItem> h = pokemon.Harvestables.Where(harvestable => harvestable.IsHarvestable).ToList();
                    _context.Pokemon.Add(pokemon);
                }
                else
                {
                    _context.Pokemon.Update(pokemon);
                }



                await _context.SaveChangesAsync();

                var uploadDir = Path.Combine(_environment.WebRootPath, $"images\\pokemon\\{pokemon.Name.ToLower()}");
                foreach (var file in files)
                {
                    if (file.Length > 0)
                    {
                        var fileGuid = Guid.NewGuid();

                        if (!Directory.Exists(uploadDir))
                        {
                            Directory.CreateDirectory(uploadDir);
                        }
                        var fsName = $"{fileGuid.ToString()}.{Path.GetExtension(file.FileName)}";

                        var filePath = Path.Combine(uploadDir, fsName);

                        var pokemonImage = new PokemonImage()
                        {
                            Pokemon        = pokemon,
                            Active         = true,
                            Caption        = "",
                            ImageName      = file.FileName,
                            FileSystemName = fsName,
                            PokemonID      = pokemon.ID
                        };

                        using (var fs = new FileStream(filePath, FileMode.Create))
                        {
                            await file.CopyToAsync(fs);
                        }

                        _context.PokemonImages.Add(pokemonImage);
                    }
                }
                if (_context.ChangeTracker.HasChanges())
                {
                    await _context.SaveChangesAsync();
                }
                return(true);
            }
            return(false);
        }
 public PokeTypesController(PokedexContext db)
 {
     _db = db;
 }
 public PokemonToPokemonTypeRepository(PokedexContext db)
 {
     Db = db;
 }
示例#14
0
 public PokemonRepository(PokedexContext db)
 {
     Db = db;
 }
示例#15
0
 public TiposController(PokedexContext context)
 {
     _context = context;
 }
 public PokemonToPokemonSkillRepository(PokedexContext db)
 {
     Db = db;
 }
 public PokemonController(PokedexContext context)
 {
     _context = context;
 }
示例#18
0
 public HomeController(PokedexContext _context, IConfigurationRoot config)
 {
     _PokedexContext = _context;
     _config         = config;
 }