public async Task <IActionResult> Edit(int id, PetBio petBio) { if (id != petBio.PetBioId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(petBio); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PetBioExists(petBio.PetBioId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } //ViewData["PetId"] = new SelectList(_context.PetAccounts, "PetAccountId", "PetAccountId", petBio.PetId); return(View(petBio)); }
// GET: PetBios/Create public IActionResult Create(int petAccountid) { PetBio petBio = new PetBio(); petBio.PetId = petAccountid; return(View(petBio)); }
public async Task <IActionResult> Create(PetBio petBio) { //petBio.PetAccount = _repo.PetBio.GetAssociatedPet(petBio.PetBioId); if (ModelState.IsValid) { _repo.PetBio.Create(petBio); _repo.Save(); return(RedirectToAction("Details", new { id = petBio.PetId })); } return(View(petBio)); }