Ejemplo n.º 1
0
        public async Task <IActionResult> PutLivro([FromRoute] int id, [FromBody] Livro livro)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != livro.Id)
            {
                return(BadRequest());
            }

            _context.Entry(livro).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LivroExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
 // PUT: api/Livro/5
 public void Put([FromBody] Livro livro)
 {
     if (ModelState.IsValid)
     {
         db.Entry(livro).State = EntityState.Modified;
         db.SaveChanges();
     }
     Dispose();
 }
 public ActionResult Edit([Bind(Include = "Id,Name")] Genero genero)
 {
     if (ModelState.IsValid)
     {
         db.Entry(genero).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(genero));
 }
Ejemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "Id,Title,YearEdition,Value,Author,GeneroId")] Livro livro)
 {
     if (ModelState.IsValid)
     {
         db.Entry(livro).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.GeneroId = new SelectList(db.Generos, "Id", "Name", livro.GeneroId);
     return(View(livro));
 }
Ejemplo n.º 5
0
        public async Task <IActionResult> PutLivroItem(long id, LivroItem item)
        {
            if (id != item.Id)
            {
                return(BadRequest());
            }

            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Ejemplo n.º 6
0
 public virtual TEntity Atualizar(TEntity entity)
 {
     _dbContext.Entry(entity).State = EntityState.Modified;
     _dbContext.SaveChanges();
     return(entity);
 }