public async Task <IActionResult> ShareNoteAsync([FromBody] Note sharedNote) { var note = await _noteService.GetNoteByIdAsync(sharedNote.Id); var user = await _userService.GetUserFromPrincipalAsync(this.User); if (note == null) { return(NotFound()); } if (note.UserId != user.Id) { return(Forbid()); } if (note.ShareKey == null) { await _noteService.AddShareKeyAsync(note); } return(Ok(new { note.ShareKey })); }