public async Task<IHttpActionResult> PutHeader(int id, Header header) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != header.Id) { return BadRequest(); } db.Entry(header).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HeaderExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostHeader(Header header) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Headers.Add(header); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = header.Id }, header); }