public async Task <IActionResult> Create([Bind("Id,Name")] Trainer trainer) { if (ModelState.IsValid) { _context.Add(trainer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(trainer)); }
public async Task <IActionResult> Create([Bind("Id,Species,Type")] Pokemon pokemon) { if (ModelState.IsValid) { _context.Add(pokemon); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(pokemon)); }
public async Task <IActionResult> Create([Bind("TrainerId,PokemonId,Name")] Catch @catch, int?id) { if (id == null) { return(NotFound()); } if (ModelState.IsValid) { @catch.TrainerId = id.Value; _context.Add(@catch); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewBag.PokeList = new SelectList(_context.Pokemon.ToList(), "Id", "Species"); return(View(@catch)); }