public async Task <ActionResult <AdjudicatorNote> > CreateAdjudicatorNote(int enrolleeId, FromBodyText note, [FromQuery] bool link) { if (!await _enrolleeService.EnrolleeExistsAsync(enrolleeId)) { return(NotFound(ApiResponse.Message($"Enrollee not found with id {enrolleeId}"))); } if (string.IsNullOrWhiteSpace(note)) { this.ModelState.AddModelError("note", "Adjudicator notes can't be null or empty."); return(BadRequest(ApiResponse.BadRequest(this.ModelState))); } var admin = await _adminService.GetAdminForUserIdAsync(User.GetPrimeUserId()); var createdAdjudicatorNote = await _enrolleeService.CreateEnrolleeAdjudicatorNoteAsync(enrolleeId, note, admin.Id); if (link) { // Link Adjudicator note to most recent status change on an enrollee if request var enrollee = await _enrolleeService.GetEnrolleeAsync(enrolleeId); await _enrolleeService.AddAdjudicatorNoteToReferenceIdAsync(enrollee.CurrentStatus.Id, createdAdjudicatorNote.Id); } return(CreatedAtAction( nameof(CreateAdjudicatorNote), new { enrolleeId = enrolleeId }, ApiResponse.Result(createdAdjudicatorNote) )); }