public async Task <IActionResult> Edit(int id, [Bind("SpeciesId,Species1,Area,IsEndangered")] Species species) { if (id != species.SpeciesId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(species); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SpeciesExists(species.SpeciesId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(species)); }
public async Task <IActionResult> Edit(int id, [Bind("PetId,SpeciesId,Name,Gender,Color")] Pet pet) { if (id != pet.PetId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(pet); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PetExists(pet.PetId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["SpeciesId"] = new SelectList(_context.Species, "SpeciesId", "Species1", pet.SpeciesId); return(View(pet)); }