public IHttpActionResult PutCustodyType(string id, CustodyType custodyType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != custodyType.custodyType1) { return(BadRequest()); } db.Entry(custodyType).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CustodyTypeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostCustodyType(CustodyType custodyType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CustodyType.Add(custodyType); try { db.SaveChanges(); } catch (DbUpdateException) { if (CustodyTypeExists(custodyType.custodyType1)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = custodyType.custodyType1 }, custodyType)); }
public IHttpActionResult DeleteCustodyType(string id) { CustodyType custodyType = db.CustodyType.Find(id); if (custodyType == null) { return(NotFound()); } db.CustodyType.Remove(custodyType); db.SaveChanges(); return(Ok(custodyType)); }