コード例 #1
0
        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);
        }
コード例 #2
0
        // 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);
        }