public IHttpActionResult PostSvcCode(SvcCode svcCode) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.SvcCodes.Add(svcCode); try { db.SaveChanges(); } catch (DbUpdateException) { if (SvcCodeExists(svcCode.SvcCodeValue)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = svcCode.SvcCodeValue }, svcCode)); }
public IHttpActionResult PutSvcCode(string id, SvcCode svcCode) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != svcCode.SvcCodeValue) { return(BadRequest()); } db.Entry(svcCode).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SvcCodeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetSvcCode(string id) { SvcCode svcCode = db.SvcCodes.Find(id); if (svcCode == null) { return(NotFound()); } return(Ok(svcCode)); }
public IHttpActionResult DeleteSvcCode(string id) { SvcCode svcCode = db.SvcCodes.Find(id); if (svcCode == null) { return(NotFound()); } db.SvcCodes.Remove(svcCode); db.SaveChanges(); return(Ok(svcCode)); }