public async Task <IActionResult> PutValue(int id, Value value) { if (id != value.Id) { return(BadRequest()); } _context.Entry(value).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ValueExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
//Método de Exclusão public virtual void Delete(TEntity obj) { using (DataContex d = new DataContex()) { d.Entry(obj).State = EntityState.Deleted; d.SaveChanges(); } }
//Método de inserção public virtual void Insert(TEntity obj) { using (DataContex d = new DataContex()) { d.Entry(obj).State = EntityState.Added; d.SaveChanges(); } }
public ActionResult Edit([Bind(Include = "Id,Name,Price,CategoryId")] Product product) { if (ModelState.IsValid) { db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(product)); }
public ActionResult Edit(Manga manga) { if (ModelState.IsValid) { db.Entry(manga).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(manga)); }
public ActionResult Edit(Product product) { if (ModelState.IsValid) { contex.Entry(product).State = EntityState.Modified; contex.SaveChanges(); return(RedirectToAction("Index", "Home")); } return(View(product)); }