public async Task <HttpResponseMessage> PutParent(string id, [FromBody] PutParentDTO updated) { string userId = ((ClaimsPrincipal)RequestContext.Principal).FindFirst(x => x.Type == "UserId").Value; string userRole = ((ClaimsPrincipal)RequestContext.Principal).FindFirst(x => x.Type == ClaimTypes.Role).Value; logger.Info("UserRole: " + userRole + ", UserId: " + userId + ": Requesting Update for Parent Id: " + id); if (updated.Id != id) { logger.Error("Updated parent id " + updated.Id + " doesn't match the id " + id + " from the request (route)."); return(Request.CreateResponse(HttpStatusCode.BadRequest, "Updated " + "parent id " + updated.Id + " doesn't match the id " + id + " from the request (route).")); } try { ParentDTOForAdmin saved = await parentsService.Update(id, updated); if (saved == null) { logger.Info("Failed!"); return(Request.CreateResponse(HttpStatusCode.BadRequest, "Failed! Something went wrong.")); } logger.Info("Success!"); return(Request.CreateResponse(HttpStatusCode.OK, saved)); } catch (Exception e) { logger.Error(e); return(Request.CreateResponse(HttpStatusCode.BadRequest, e)); } }