예제 #1
0
 public IActionResult Create(CreatePokemonViewModel createPokemonViewModel, ICollection <IFormFile> files)
 {
     if (PokemonHelper.ProcessImages(files, createPokemonViewModel.pokemon, _context, _environment, ModelState).Result)
     {
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View());
     }
 }
예제 #2
0
        public IActionResult Edit(
            int id,
            [Bind("ID,BaseAttack,BaseDefense,BaseSpecialAttack,BaseHitpoints,BaseSpecialDefense,BaseSpeed,Harvestables,Description,IsInMod,Name,PokedexNumber,tamingType")] Pokemon pokemon,
            ICollection <IFormFile> files)
        {
            if (id != pokemon.ID)
            {
                return(NotFound());
            }


            try
            {
                if (PokemonHelper.ProcessImages(files, pokemon, _context, _environment, ModelState).Result)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(pokemon));
                }
                //_context.Update(pokemon);
                //await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PokemonExists(pokemon.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }


            //return View(pokemon);
        }