public IHttpActionResult PutOffer(int id, Offer offer) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != offer.id) { return BadRequest(); } db.Entry(offer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!OfferExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostOffer(Offer offer) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Offers.Add(offer); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = offer.id }, offer); }