Exemple #1
0
        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));
        }
Exemple #3
0
        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());
        }
Exemple #4
0
 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));
 }
Exemple #5
0
        public virtual TEntity Atualizar(TEntity obj)
        {
            var entry = Db.Entry(obj);

            DbSet.Attach(obj);
            entry.State = EntityState.Modified;
            SaveChanges();

            return(obj);
        }