public async Task<IHttpActionResult> PutponctualEvent(int id, ponctualEvent ponctualEvent) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != ponctualEvent.eventId) { return BadRequest(); } //db.Entry(ponctualEvent.@event).State = EntityState.Modified; db.Entry(ponctualEvent).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ponctualEventExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostponctualEvent(ponctualEvent ponctualEvent) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.ponctualEvent.Add(ponctualEvent); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (ponctualEventExists(ponctualEvent.eventId)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = ponctualEvent.eventId }, ponctualEvent); }