public async Task <IActionResult> PutActivity([FromRoute] int id, [FromBody] Activity activity) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (activity.ActivityId == 0) { activity.ActivityId = id; } if (id != activity.ActivityId) { return(BadRequest()); } _context.Entry(activity).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ActivityExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutUser([FromRoute] int id, [FromBody] User user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != user.UserId) { return(BadRequest()); } _context.Entry(user).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }