public async Task <IActionResult> PutProduto(long id, Produto produto) { if (id != produto.Id) { return(BadRequest()); } _context.Entry(produto).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProdutoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCategory(int id, Category category) { if (id != category.CategoryID) { return(BadRequest()); } _context.Entry(category).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit([Bind(Include = "ProductID,Name,UnitsInStock,CategoryId,UnitPrice")] Product product) { if (ModelState.IsValid) { db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(product)); }
public ActionResult Edit([Bind(Include = "CategoryID,Name,Description")] Category category) { if (ModelState.IsValid) { db.Entry(category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
private void btnEdit_Click(object sender, EventArgs e) { category.Name = txtName.Text.Trim(); category.Description = txtDescription.Text.Trim(); db.Entry(category).State = EntityState.Modified; db.SaveChanges(); MessageBox.Show("Category successfully modified"); this.categoryDataGridView.Refresh(); Clear(); }