public async Task <IActionResult> Edit(int id, [Bind("ID,ShopID,Number,Square")] Cage cage) { cage.ShopID = shopId; cage.Shop = _context.Shops.Where(s => s.ID == shopId).First(); if (id != cage.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cage); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CageExists(cage.ID)) { return(NotFound()); } else { throw; } } return(Redirect("https://localhost:44324/Cages/Details/" + shopId)); } return(View(cage)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Adress")] Shop shop) { if (id != shop.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(shop); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShopExists(shop.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(shop)); }
public void UpdateAnimal(Animal animal) { try { _context.Update(animal); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { throw new Exception("Error on inserting"); } }