public IHttpActionResult putAssetType(int id, Asset_type asset_type) { //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} if (id != asset_type.at_id) { return(BadRequest()); } db.Entry(asset_type).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!Asset_typeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult getAssetType(int id) { Asset_type asset_type = db.Asset_type.Find(id); if (asset_type == null) { return(NotFound()); } return(Ok(asset_type)); }
public IHttpActionResult postAssetType(Asset_type asset_type) { //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} db.Asset_type.Add(asset_type); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = asset_type.at_id }, asset_type)); }
public IHttpActionResult deleteAssetType(int id) { Asset_type asset_type = db.Asset_type.Find(id); if (asset_type == null) { return(NotFound()); } db.Asset_type.Remove(asset_type); db.SaveChanges(); return(Ok(asset_type)); }