public async Task <IHttpActionResult> PutCostStructure(int id, CostStructure costStructure) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != costStructure.Id) { return(BadRequest()); } db.Entry(costStructure).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CostStructureExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetCostStructure(int id) { CostStructure costStructure = await db.CostStructures.FindAsync(id); if (costStructure == null) { return(NotFound()); } return(Ok(costStructure)); }
public async Task <IHttpActionResult> PostCostStructure(CostStructure costStructure) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CostStructures.Add(costStructure); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = costStructure.Id }, costStructure)); }
public async Task <IHttpActionResult> DeleteCostStructure(int id) { CostStructure costStructure = await db.CostStructures.FindAsync(id); if (costStructure == null) { return(NotFound()); } db.CostStructures.Remove(costStructure); await db.SaveChangesAsync(); return(Ok(costStructure)); }