public IHttpActionResult PostClientSvcCode(ClientSvcCode clientSvcCode) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ClientSvcCodes.Add(clientSvcCode); try { db.SaveChanges(); } catch (DbUpdateException) { if (ClientSvcCodeExists(clientSvcCode.ClientId)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = clientSvcCode.ClientId }, clientSvcCode)); }
public IHttpActionResult PutClientSvcCode(int id, ClientSvcCode clientSvcCode) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != clientSvcCode.ClientId) { return(BadRequest()); } db.Entry(clientSvcCode).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ClientSvcCodeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetClientSvcCode(int id) { ClientSvcCode clientSvcCode = db.ClientSvcCodes.Find(id); if (clientSvcCode == null) { return(NotFound()); } return(Ok(clientSvcCode)); }
public IHttpActionResult DeleteClientSvcCode(int id) { ClientSvcCode clientSvcCode = db.ClientSvcCodes.Find(id); if (clientSvcCode == null) { return(NotFound()); } db.ClientSvcCodes.Remove(clientSvcCode); db.SaveChanges(); return(Ok(clientSvcCode)); }