// POST: odata/Heartbeats public async Task <IHttpActionResult> Post(Heartbeat heartbeat) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } // each heartbeat must be unique if (heartbeat.Id == Guid.Empty) { heartbeat.Id = Guid.NewGuid(); } //generate event args for delegate HeartbeatEventArgs e = RxStreamHelper.GetHeartbeatEventArgs(heartbeat); //propagate the heartbeat heartbeatDelegate(this, e); //insert into db db.Heartbeats.Add(heartbeat); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (HeartbeatExists(heartbeat.Id)) { return(Conflict()); } else { throw; } } return(Created(heartbeat)); }
static WebRole() { //initialize Rx streams RxHelper = new RxStreamHelper(); }