public IHttpActionResult PutEstiloCerveja(int id, EstiloCerveja estiloCerveja) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != estiloCerveja.IDEstilo) { return(BadRequest()); } db.Entry(estiloCerveja).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EstiloCervejaExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetEstiloCerveja(int id) { EstiloCerveja estiloCerveja = db.EstiloCerveja.Find(id); if (estiloCerveja == null) { return(NotFound()); } return(Ok(estiloCerveja)); }
public IHttpActionResult PostEstiloCerveja(EstiloCerveja estiloCerveja) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.EstiloCerveja.Add(estiloCerveja); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = estiloCerveja.IDEstilo }, estiloCerveja)); }
public IHttpActionResult DeleteEstiloCerveja(int id) { EstiloCerveja estiloCerveja = db.EstiloCerveja.Find(id); if (estiloCerveja == null) { return(NotFound()); } db.EstiloCerveja.Remove(estiloCerveja); db.SaveChanges(); return(Ok(estiloCerveja)); }