public async Task <IActionResult> Crear([Bind("Region")] Regiones regiones) { if (ModelState.IsValid) { _context.Add(regiones); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(regiones)); }
public async Task <IActionResult> Create([Bind("TiposId,NombreT")] Tipos tipos) { if (ModelState.IsValid) { _context.Add(tipos); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tipos)); }
public async Task <IActionResult> Create([Bind("ID,AuthoredBy,Body,DatePosted,SubTitle,Title")] HomeContent homeContent) { if (ModelState.IsValid) { _context.Add(homeContent); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(homeContent)); }
public IActionResult Nuevo(Pokemon p) { if (ModelState.IsValid) { // Guardar el objeto Pokemon (p) _context.Add(p); _context.SaveChanges(); return(RedirectToAction("Lista")); } return(View(p)); }
public async Task <IActionResult> Create([Bind("PokeId,Nombre,Tipo1,Tipo2,Region,Move1,Move2,Move3,Move4,Foto")] Pokemon pokemon) { if (ModelState.IsValid) { _context.Add(pokemon); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Region"] = new SelectList(_context.Regiones, "RegId", "NombreR", pokemon.Region); ViewData["Tipo1"] = new SelectList(_context.Tipos, "TiposId", "NombreT", pokemon.Tipo1); ViewData["Tipo2"] = new SelectList(_context.Tipos, "TiposId", "NombreT", pokemon.Tipo2); return(View(pokemon)); }
public async Task <IActionResult> Crear(TipoViewModel tipo) { if (ModelState.IsValid) { var tip = new Tipo { Tipos = tipo.Tipos }; _context.Add(tip); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tipo)); }
public async Task <IActionResult> Create(PokemonViewModel pokemon) { if (ModelState.IsValid) { var pokemo = new Pokemon { Nombre = pokemon.Nombre, Tipo = pokemon.Tipo, Tipo2 = pokemon.Tipo2, Ataques = pokemon.Ataques, Ataque2 = pokemon.Ataque2, Ataque3 = pokemon.Ataque3, Ataque4 = pokemon.Ataque4, Region = pokemon.Region }; _contex.Add(pokemo); await _contex.SaveChangesAsync(); } return(RedirectToAction("Index")); }