public IHttpActionResult PutSmart(int id, Smart smart) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != smart.SmartId) { return BadRequest(); } db.Entry(smart).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SmartExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostSmart(Smart smart) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Smarts.Add(smart); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = smart.SmartId }, smart); }