public async Task <IActionResult> PutAutor([FromRoute] int id, [FromBody] Autor autor) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != autor.AutorId) { return(BadRequest()); } _context.Entry(autor).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AutorExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Name")] Category category) { if (ModelState.IsValid) { db.Entry(category).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(category)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Title,Text,Asked,ViewCount,AnswerCount,VoteCount")] Question question) { if (ModelState.IsValid) { db.Entry(question).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(question)); }
public void Remove(TEntity obj) { _context.Entry(obj).State = EntityState.Deleted; _context.SaveChanges(); }
public void Alterar(TClass obj) { db.Entry(obj).State = Microsoft.EntityFrameworkCore.EntityState.Modified; db.SaveChanges(); }
public IActionResult Edit(Post Post) { _db.Entry(Post).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }