public IHttpActionResult PutCalendarEvent(int id, CalendarEvent calendarEvent) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != calendarEvent.CalendarEventId) { return BadRequest(); } db.Entry(calendarEvent).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CalendarEventExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostCalendarEvent(CalendarEvent calendarEvent) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.CalendarEvents.Add(calendarEvent); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = calendarEvent.CalendarEventId }, calendarEvent); }