コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre,Ataque1,Ataque2,Ataque3,Ataque4,Region,Tipo")] Pokemon pokemon)
        {
            if (id != pokemon.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pokemon);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PokemonExists(pokemon.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Region"] = new SelectList(_context.Region, "Id", "Nombre", pokemon.Region);
            ViewData["Tipo"]   = new SelectList(_context.Tipo, "Id", "Tipo1", pokemon.Tipo);
            return(View(pokemon));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre")] Region region)
        {
            if (id != region.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(region);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RegionExists(region.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(region));
        }
コード例 #3
0
ファイル: TiposController.cs プロジェクト: Juand0014/Pokedex3
        public async Task <IActionResult> Edit(int id, [Bind("Id,Tipo1")] Tipo tipo)
        {
            if (id != tipo.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tipo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TipoExists(tipo.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tipo));
        }