public IActionResult Put(Guid reviewId, [FromBody] JObject value) { Guid userId; try { userId = value["userId"].ToObject <Guid>(); } catch (Exception e) { Failure failure = FailureFact.BadUserId(e, value["userId"]); db.InsertRecordAsync(FAILURE_TABLE, failure); return(BadRequest(failure)); } List <Section> sections = null; List <Guid> comments = null; try { if (value["sections"] != null) { sections = value["sections"].ToObject <List <Section> >(); } else { comments = value["comments"].ToObject <List <Guid> >(); } } catch (Exception e) { Failure failure = FailureFact.BadRequestBody(e, userId, value["sections"]); db.InsertRecordAsync(FAILURE_TABLE, failure); return(BadRequest(failure)); } Review record; try { record = db.FindRecordById <Review>(REVIEW_TABLE, reviewId); } catch (Exception e) { Failure failure = FailureFact.Default(e, userId); db.InsertRecordAsync(FAILURE_TABLE, failure); return(StatusCode(500, failure)); } if (record == null) { Failure failure = FailureFact.IdNotFound(null, userId, reviewId); db.InsertRecordAsync(FAILURE_TABLE, failure); return(NotFound(failure)); } if (sections != null) { record.SetSection(sections, userId); } else { record.SetComments(comments, userId); } db.PutRecord(REVIEW_TABLE, value, reviewId); Success success = SuccessFact.ReviewSectionsModified(reviewId, userId, sections); db.InsertRecordAsync(SUCCESS_TABLE, success); return(NoContent()); }