public IHttpActionResult PutMyThing(int id, MyThing myThing) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != myThing.id) { return BadRequest(); } db.Entry(myThing).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MyThingExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostMyThing(MyThing myThing) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.MyThings.Add(myThing); db.SaveChanges(); try { NotificationClass notClass = new NotificationClass(); Thread notificationThread = new Thread(async x => { await notClass.SendNotificationAsync(myThing.rfid); }); notificationThread.Start(); } catch { } return CreatedAtRoute("DefaultApi", new { id = myThing.id }, myThing); }