public async Task<IHttpActionResult> PutEvent(int id, Event @event) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != @event.Id) { return BadRequest(); } db.Entry(@event).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EventExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostEvent(Event @event) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Events.Add(@event); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = @event.Id }, @event); }