public async Task <IActionResult> Edit(int id, [Bind("GenreId,GenreName")] Genre genre) { if (id != genre.GenreId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(genre); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GenreExists(genre.GenreId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(genre)); }
public async Task <IActionResult> Edit(int id, [Bind("BranchId,BranchName,City,Address,Latitude,Longitude,PhoneNumber")] Branch branch) { if (id != branch.BranchId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(branch); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BranchExists(branch.BranchId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(branch)); }
public async Task <IActionResult> PutAsync(int id, [FromBody] Book bookToUpdate) { var book = await _context.Books.FindAsync(id); if (book == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest()); } _context.Update(bookToUpdate); await _context.SaveChangesAsync(); return(Ok()); }