public async Task <IHttpActionResult> PutCostStructureItem(int id, CostStructureItem costStructureItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != costStructureItem.Id) { return(BadRequest()); } db.Entry(costStructureItem).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CostStructureItemExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetCostStructureItem(int id) { CostStructureItem costStructureItem = await db.CostStructureItems.FindAsync(id); if (costStructureItem == null) { return(NotFound()); } return(Ok(costStructureItem)); }
public async Task <IHttpActionResult> PostCostStructureItem(CostStructureItem costStructureItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CostStructureItems.Add(costStructureItem); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = costStructureItem.Id }, costStructureItem)); }
public async Task <IHttpActionResult> DeleteCostStructureItem(int id) { CostStructureItem costStructureItem = await db.CostStructureItems.FindAsync(id); if (costStructureItem == null) { return(NotFound()); } db.CostStructureItems.Remove(costStructureItem); await db.SaveChangesAsync(); return(Ok(costStructureItem)); }