public async Task<IHttpActionResult> PutBinder(int id, Binder binder) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != binder.Id) { return BadRequest(); } db.Entry(binder).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BinderExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostBinder(Binder binder) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Binder.Add(binder); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = binder.Id }, binder); }
// POST: odata/Binders public async Task<IHttpActionResult> Post(Binder binder) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Binder.Add(binder); await db.SaveChangesAsync(); return Created(binder); }