public async Task<IHttpActionResult> PutSawYouEntry(int id, SawYouEntry sawYouEntry) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != sawYouEntry.Id) { return BadRequest(); } db.Entry(sawYouEntry).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SawYouEntryExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostSawYouEntry(SawYouEntry sawYouEntry) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.SawYouEntry.Add(sawYouEntry); await db.SaveChangesAsync(); var _contex = GlobalHost.ConnectionManager.GetHubContext<SawYouHub>(); _contex.Clients.All.newEntry(sawYouEntry); return CreatedAtRoute("DefaultApi", new { id = sawYouEntry.Id }, sawYouEntry); }