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