public virtual IActionResult Put(int id, [FromBody] T entity) { if (entity == null || entity.Id != id) { return(BadRequest("Object reference not set to an instance of an object")); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var oldEntity = repo.Get(id); if (oldEntity == null) { try { HttpContext.Response.StatusCode = 404; return(Json(new { message = $"{typeof(T).Name} not found" })); } catch (Exception) { return(NotFound()); } } string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; repo.Edit(entity); return(new NoContentResult()); }