public IHttpActionResult PutEditoras(int id, Editoras editoras) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != editoras.Id) { return(BadRequest()); } db.Entry(editoras).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EditorasExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutLocacao(int id, Locacao locacao) { if (!ModelState.IsValid) { if (ModelState.Keys.First().ToString() != "locacao.Id") { return(BadRequest(ModelState)); } } if (id != locacao.Id) { return(BadRequest()); } db.Entry(locacao).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LocacaoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> PutImovel(int id, Imovel imovel) { if (id != imovel.Id) { return(BadRequest()); } _context.Entry(imovel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ImovelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IHttpActionResult PutLivros(int id, Livros livros) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != livros.Id) { return BadRequest(); } db.Entry(livros).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LivrosExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PutGeneros(int id, Generos generos) { if (!ModelState.IsValid) { if (ModelState.Keys.First() != "generos.Id") { return(BadRequest(ModelState)); } } if (id != generos.Id) { return(BadRequest()); } db.Entry(generos).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!GenerosExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> PutProprietario(int id, Proprietario proprietario) { if (id != proprietario.Id) { return(BadRequest()); } _context.Entry(proprietario).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProprietarioExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }