public async Task <ActionResult <Child> > Put(int id, [FromBody] Child child) { if (child.ID != id) { return(BadRequest()); } _context.Entry(child).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!_context.Children.Any(c => c.ID == id)) { return(NotFound()); } else { throw; } } return(Ok(child)); }
//[Authorize(Roles = "Admin")] public async Task <IActionResult> PutChild([FromRoute] int id, [FromBody] Child child) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != child.Id) { return(BadRequest()); } _context.Entry(child).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ChildExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }