public async Task <IActionResult> PostEvent([FromBody] ContentService.Models.Page @page) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Pages.Add(@page); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (PageExists(@page.PageId)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetPage", new { id = @page.PageId }, @page)); }
public async Task <IActionResult> PutPage([FromRoute] int id, [FromBody] ContentService.Models.Page @page) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != @page.PageId) { return(BadRequest()); } _context.Entry(@page).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PageExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }