public async Task <ActionResult> Put(int id, Permit entity) { // Validate that the params are from the same entity to avoid injection attacks. TLDR; if (id != entity.Id) { return(BadRequest()); } try { _service.Update(entity); await _service.SaveChanges(); } catch (Exception) { return(BadRequest(new { entity = entity, message = "There was a problem updating the Permit" })); } return(NoContent()); }