public async Task <Tarefa> Put(Tarefa tarefa) { _tarefaContext.Entry(tarefa).State = EntityState.Modified; await _tarefaContext.SaveChangesAsync(); return(tarefa); }
public IHttpActionResult PutTarefa(int id, Tarefa tarefa) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tarefa.Id) { return(BadRequest()); } db.Entry(tarefa).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TarefaExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> PutTarefa([FromRoute] long id, [FromBody] Tarefa tarefa) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tarefa.Id) { return(BadRequest()); } _context.Entry(tarefa).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TarefaExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit([Bind(Include = "ID,Data,Titulo,Nota,Lido")] Tarefa tarefa) { if (ModelState.IsValid) { db.Entry(tarefa).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tarefa)); }
public virtual TEntity Atualizar(TEntity obj) { var entry = Db.Entry(obj); DbSet.Attach(obj); entry.State = EntityState.Modified; SaveChanges(); return(obj); }