public IHttpActionResult PostIndication(Indication indication) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Indication.Add(indication); try { db.SaveChanges(); } catch (DbUpdateException) { if (IndicationExists(indication.Id)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = indication.Id }, indication); }
public IHttpActionResult PutIndication(int id, Indication indication) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != indication.Id) { return BadRequest(); } db.Entry(indication).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!IndicationExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }