public async Task <IActionResult> Update(int id, [FromBody] Product product) { if (id != product.IdProduct) { return(BadRequest()); } try { _context.Update(product); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(Content("Product updated successfull")); }
public async Task <IActionResult> Edit(int id, [Bind("IdProduct,ProductCode,ProductType,Description,UnitPrice,QtyInStock")] Product product) { if (id != product.IdProduct) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(product); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(product.IdProduct)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(product)); }
public async Task <IActionResult> Edit(int id, [Bind("playerId,playerName,playerNumber,teamName")] Player player) { if (id != player.playerId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(player); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlayerExists(player.playerId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(player)); }