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()); }
public async Task <IActionResult> PutRaspberryRecord([FromRoute] int id, [FromBody] RaspberryRecord raspberryRecord) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != raspberryRecord.RecordId) { return(BadRequest()); } _context.Entry(raspberryRecord).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RaspberryRecordExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }