public async Task <IActionResult> Edit(int id, [Bind("OwnerId,FirstName,LastName,email,Photo,PhoneNumber")] Owner owner) { if (id != owner.OwnerId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(owner); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OwnerExists(owner.OwnerId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(owner)); }
public async Task <IActionResult> Edit(int id, [Bind("PetId,Name,OwnerId,Age,Picture")] 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["OwnerId"] = new SelectList(_context.Owners, "OwnerId", "OwnerId", pet.OwnerId); return(View(pet)); }