public async Task<IHttpActionResult> PostCalendarEvent(CalendarEvent calendarEvent) { if (!ModelState.IsValid) { return BadRequest(ModelState); } await repository.AddAsync(calendarEvent); return CreatedAtRoute("DefaultApi", new { id = calendarEvent.CalendarEventID }, calendarEvent); }
// PUT api/CalendarEvents/5 public async Task<IHttpActionResult> PutCalendarEvent(int id, CalendarEvent calendarEvent) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != calendarEvent.CalendarEventID) { return BadRequest(); } await repository.UpdateAsync(calendarEvent, calendarEvent.CalendarEventID); return StatusCode(HttpStatusCode.NoContent); }