public IHttpActionResult PutSetorCliente(int id, SetorCliente setorCliente) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != setorCliente.Id) { return(BadRequest()); } db.Entry(setorCliente).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SetorClienteExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetSetorCliente(int id) { SetorCliente setorCliente = db.SetorClientes.Find(id); if (setorCliente == null) { return(NotFound()); } return(Ok(setorCliente)); }
public IHttpActionResult PostSetorCliente(SetorCliente setorCliente) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.SetorClientes.Add(setorCliente); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = setorCliente.Id }, setorCliente)); }
public IHttpActionResult DeleteSetorCliente(int id) { SetorCliente setorCliente = db.SetorClientes.Find(id); if (setorCliente == null) { return(NotFound()); } db.SetorClientes.Remove(setorCliente); db.SaveChanges(); return(Ok(setorCliente)); }